5

I created a virtual environment named sampleenv, however when I launched jupyter notebook inside sampleenv, I noticed that it is referencing/siting python packages from my another virtual environment named openfaceenv. Here's the output when calling sys.path and sys.executable inside jupyter notebook:

(Inside jupyter notebook in sampleenv)

import sys
print sys.path

['', '/Users/user/.virtualenvs/sampleenv/lib/python2.7/site-packages', '', '/Users/user/.virtualenvs/openfaceenv/lib/python2.7/site-packages/dlib-18.18.99-py2.7-macosx-10.10-x86_64.egg', '/Users/user', '/Users/user/git-repos', '/Users/user/.virtualenvs/openfaceenv/lib/python27.zip', '/Users/user/.virtualenvs/openfaceenv/lib/python2.7', '/Users/user/.virtualenvs/openfaceenv/lib/python2.7/plat-darwin', '/Users/user/.virtualenvs/openfaceenv/lib/python2.7/plat-mac', '/Users/user/.virtualenvs/openfaceenv/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/user/.virtualenvs/openfaceenv/lib/python2.7/lib-tk', '/Users/user/.virtualenvs/openfaceenv/lib/python2.7/lib-old', '/Users/user/.virtualenvs/openfaceenv/lib/python2.7/lib-dynload', '/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/user/.virtualenvs/openfaceenv/lib/python2.7/site-packages', '/Users/user/.virtualenvs/openfaceenv/lib/python2.7/site-packages/IPython/extensions', '/Users/user/.ipython']

print sys.executable

/Users/user/.virtualenvs/openfaceenv/bin/python2.7

However when I ran ipython or python shell in command line in sampleenv and get the sys.path and sys.executable both of them correctly sites the right path, That is,

(Inside a python shell or ipython shell in sampleenv)

import sys
print sys.path

['', '/Users/user', '/Users/user/git-repos', '/Users/user/.virtualenvs/sampleenv/lib/python27.zip', '/Users/user/.virtualenvs/sampleenv/lib/python2.7', '/Users/user/.virtualenvs/sampleenv/lib/python2.7/plat-darwin', '/Users/user/.virtualenvs/sampleenv/lib/python2.7/plat-mac', '/Users/user/.virtualenvs/sampleenv/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/user/.virtualenvs/sampleenv/lib/python2.7/lib-tk', '/Users/user/.virtualenvs/sampleenv/lib/python2.7/lib-old', '/Users/user/.virtualenvs/sampleenv/lib/python2.7/lib-dynload', '/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/user/.virtualenvs/sampleenv/lib/python2.7/site-packages']

print sys.executable

'/Users/user/.virtualenvs/sampleenv/bin/python'

Why is this so? How can I fix this? Also, when I tried to switch to other virtual envs, same issue, it is pointing the path to that of the openfaceenv site-packages.I already look at the related problems, but their solution doesn't really solve the problem, I don't want to use sys.path.append(), also I tried running hash -r, but same result.

bninopaul
  • 2,659
  • 4
  • 15
  • 22

0 Answers0