0

I was trying to install the Adafruit_Python_MPR121 Library in my venv folder, but it always installed it into the global dist-packages and I cannot access them from my venv. I cannot use --site-packages because I need some local packages in the env.

Does someone know a solution for it?

1 Answers1

0

I'm sure you can and should use --site-packages. It doesn't do what you seem to think it does — it doesn't make pip install all packages globally. It makes python in the virtual env access global site-packages but pip still install packages in the virtual env (after you activate it with . env/bin/activate).

phd
  • 82,685
  • 13
  • 120
  • 165
  • thanks for your answer, but when i remove the site-packages from an existing env, then i cannot access those site-packages that were only installed in that env, right? – zorosenpai Feb 01 '18 at 19:33
  • Why do you want to remove the `site-packages` directory? It is beyond me. If you have a virtual env you can choose what to install globally and what to install in the env. Packages in the env are available only to programs running with python interpreter from the env. Global packages are available to the global python and to those virtual envs that have been created with `--site-packages` option. – phd Feb 01 '18 at 20:09
  • i have an existing env and i wasn‘t set up with —site-packages. with remove i ment to add the txt file that makes the — site-packages option after creation without that option. or is there another way to work with my existing env without that option and to access certain global but also the packages in the env? – zorosenpai Feb 02 '18 at 07:26
  • Ah, that text file — it's ok with me. I usually don't do it manually — I use virtualenvwrapper's `togglesitepackages` command. – phd Feb 02 '18 at 07:28
  • i don’t use the virtualenvwrapper, is there a way to do it manually? – zorosenpai Feb 02 '18 at 07:39
  • Remove `no-global-site-packages.txt`. See how [virtualenvwrapper does it](https://bitbucket.org/virtualenvwrapper/virtualenvwrapper/src/36b8050a90192a087d1060f32083249d13d8a215/virtualenvwrapper.sh?at=master&fileviewer=file-view-default#virtualenvwrapper.sh-935). – phd Feb 02 '18 at 08:00