0

I have installed several packages as sudoer using sudo pip install package_name command. The packages are installed and work well in this user. Afterwards, I have defined a new user. My problem is that the packages are not available in the new user and when trying to import them this error is appeared: No module named package_name. Is there any way in which I do not need to reinstall the packages for new user and use the packages installed by the sudoer?

Quasar
  • 11
  • 5

2 Answers2

0

You can try 2 things here:

  1. Try using the --user flag with pip something like: pip install --user <package>, so as to install the package for the user with which you are running your python code.

  2. Get inside virtualenv of your project and install the dependency from your virtual environment. You can read more about virtual environment here.

piy26
  • 1,574
  • 11
  • 21
  • Thanks @piy26 for your answer. But, I am looking for a way in which I do not need to install again the installed packages for every new user. I mean they can use the packages installed by the root and not to install them again... – Quasar Jul 06 '18 at 10:48
0

The environment variables must be defined for the new user again.Try setting the environment variables for python and pip for the new user

venkatesh .b
  • 83
  • 1
  • 1
  • 7
  • Try https://stackoverflow.com/questions/234742/setting-environment-variables-in-linux-using-bash – venkatesh .b Jul 06 '18 at 09:29
  • Or try https://unix.stackexchange.com/questions/21598/how-do-i-set-a-user-environment-variable-permanently-not-session To set the environment variables – venkatesh .b Jul 06 '18 at 09:29
  • Thanks for your reply @venkatesh-b . I somehow understood how your proposed method works, but I did not understand what should I exactly do. Would you please explain in details? – Quasar Jul 06 '18 at 11:18