Skip to content

Installing Python modules for import in the service script #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aspence opened this issue Sep 28, 2021 · 4 comments
Closed

Installing Python modules for import in the service script #14

aspence opened this issue Sep 28, 2021 · 4 comments

Comments

@aspence
Copy link

aspence commented Sep 28, 2021

This is a fantastic tutorial thank you! I have a quick question:

What is the correct way to install Python packages so that they can be imported in the service python script under the dedicated service user?

E.g., i'd like to import gpustat or pySMART inside the Python script, but I believe it says module not found, no doubt because conda or pip had installed those packages in my normal user environment.

Thank you!

@Olegt0rr
Copy link

  1. Install requirements to venv
  2. Give permissions to venv for your service user

@aspence
Copy link
Author

aspence commented Sep 28, 2021

Awesome thank you Oleg - do i need to log into service user account to set this venv up, or can I create the venv under another user and then point the service script to it by choice of /usr/bin/python etc? cheers

@aspence
Copy link
Author

aspence commented Sep 28, 2021

Basically - how do I ensure when systemd calls the script as the service user the venv is activated?

@aspence
Copy link
Author

aspence commented Sep 28, 2021

Got it... TY
https://stackoverflow.com/questions/37211115/how-to-enable-a-virtualenv-in-a-systemd-service-unit

@aspence aspence closed this as completed Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants