我已在我的virtualenv的激活文件的最底部添加了以下行:
export PYTHONPATH="/home/ola/projects/core/feature/src/"
如果运行以下命令,我可以正确地将目录更改为所需的目录,因此
ola@pad:~$ source /home/ola/projects/core/feature/srv/vfeature/bin/activate
(vfeature) ola@pad:~$ echo $PYTHONPATH
/home/ola/projects/core/feature/src/
(vfeature) ola@pad:~$ cd $PYTHONPATH
(vfeature) ola@pad:~/projects/core/feature/src$
在启用了virtualenv的python中,它不显示目录:
In [7]: sys.path
Out[7]:
['',
'/home/ola/projects/core/feature/srv/vfeature/bin',
'/home/ola/projects/core/feature/srv/vfeature/lib/python35.zip',
'/home/ola/projects/core/feature/srv/vfeature/lib/python3.5',
'/home/ola/projects/core/feature/srv/vfeature/lib/python3.5/plat-x86_64-linux-gnu',
'/home/ola/projects/core/feature/srv/vfeature/lib/python3.5/lib-dynload',
'/usr/lib/python3.5',
'/usr/lib/python3.5/plat-x86_64-linux-gnu',
'/home/ola/projects/core/feature/srv/vfeature/lib/python3.5/site-packages',
'/home/ola/projects/core/feature/srv/vfeature/lib/python3.5/site-packages/IPython/extensions',
'/home/ola/.ipython',
'~/projects/core/']