我正在尝试使用Nervana创建的virtualenv中的pytools模块作为他们的Neon深度学习包,但似乎无法找到pytools或pip它.当我进入virtualenv时,我看到了这种行为:
me@ARL--M6800:~/Downloads/neon$source .venv/bin/activate
(.venv) me@ARL--M6800:~/Downloads/neon$python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytools
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named pytools
>>>
>>> import sys
>>> sys.path
['', '/usr/local/lib/python2.7/dist-packages', '/home/me/Downloads/neon',
'/home/me/Downloads/neon/.venv/lib/python2.7',
'/home/me/Downloads/neon/.venv/lib/python2.7/plat-x86_64-linux-gnu',
'/home/me/Downloads/neon/.venv/lib/python2.7/lib-tk',
'/home/me/Downloads/neon/.venv/lib/python2.7/lib-old',
'/home/me/Downloads/neon/.venv/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/home/me/Downloads/neon/.venv/local/lib/python2.7/site-packages',
'/home/me/Downloads/neon/.venv/lib/python2.7/site-packages']
(.venv) me@ARL--M6800:~/Downloads/neon$pip install pytools
Requirement already satisfied (use --upgrade to upgrade): pytools in
/usr/local/lib/python2.7/dist-packages/pytools-2016.1-py2.7.egg
Requirement already satisfied (use --upgrade to upgrade):
decorator>=3.2.0 in /usr/local/lib/python2.7/dist-packages (from pytools)
Requirement already satisfied (use --upgrade to upgrade): appdirs>=1.4.0
in /usr/local/lib/python2.7/dist-packages/appdirs-1.4.0-py2.7.egg (from
pytools)
Requirement already satisfied (use --upgrade to upgrade): six>=1.8.0 in
/usr/local/lib/python2.7/dist-packages (from pytools)
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6.0 in
/usr/local/lib/python2.7/dist-packages (from pytools)
所以,我无法导入pytools,因为它不在我的sys.path上.根据pip,它安装在/usr/local/lib/python2.7/dist-packages/pytools-2016.1-py2.7.egg目录中,这给我留下了3个问题:
第一:为什么我的virtualenv可以看到我的系统级软件包?我以为默认不是看他们.当我看到用于创建virtualenv的Makefile时,我看到了这一点
# where our installed python packages will live
VIRTUALENV_DIR := .venv
VIRTUALENV_EXE := virtualenv -p python2.7 # use pyvenv for python3 install
ACTIVATE := $(VIRTUALENV_DIR)/bin/activate
哪个应该给我默认行为.
第二:为什么我的dist-packages目录中有egg目录?这不是更难找到这些模块吗? (虽然显然,我的系统环境python的sys.path已更新为在egg目录中搜索.当/如何???
第三:什么是修复事物的有效方法,以便我的virtualenv可以访问pytools?
(我会将我的列表编号而不是第一/第二/第三,但是我插入的Makefile代码格式不正确)