Add2virtualenv (virtualenv wrapper) does not work with scipy

I want to create virtualenv without global python packages, but with a common scipy distribution; scipy installation takes a lot of time, and I do not want to go through the movements too often.

So, I run add2virtualenv /Library/Python/2.7/site-packages/scipy , and after running add2virtualenv it shows that the directory has been added. (I checked twice, this is the correct directory). I then workon myfile to make sure the working directories are reloaded. However, when I try to load scipy, it is ImportError: No module named scipy . This was unexpected.

Has anyone used global scipy in a non-global-sitepackages virtual server?

+6
source share
1 answer

So, summarizing, the actual problem is that the directory containing the imported packages should be used instead of a specific package. That is, instead of

 add2virtualenv /Library/Python/2.7/site-packages/scipy 

It should be

 add2virtualenv /Library/Python/2.7/site-packages 

Beware: this solution has the drawback that you not only include scipy, but other packages in /Library/Python/2.7/site-packages .


An alternative solution with spatial resolution could be the symbolic scipy directory inside the virtual env site package. This can be done in your virtual env using:

 cdsitepackages ln -s /Library/Python/2.7/site-packages/scipy scipy 

All loans go to @rubik (see comments)

Check this answer to find the path to your sites if it differs from the one used here.

+3
source

Source: https://habr.com/ru/post/915293/


All Articles