在virtualenv中找不到Python模块
我已尝试安装python模块:在virtualenv中找不到Python模块,python,python-2.7,module,pip,virtualenv,Python,Python 2.7,Module,Pip,Virtualenv,我已尝试安装python模块: virtualenv . source bin/activate pip install utmp 它似乎安装在: (wtmp)chris@chris-nb:~/computer/wtmp$ find -iname utmp ./bin/utmp ./lib/python2.7/site-packages/utmp 但是Python说没有找到它: (wtmp)chris@chris-nb:~/computer/wtmp$ ./wtmp.py Traceback
virtualenv .
source bin/activate
pip install utmp
它似乎安装在:
(wtmp)chris@chris-nb:~/computer/wtmp$ find -iname utmp
./bin/utmp
./lib/python2.7/site-packages/utmp
但是Python说没有找到它:
(wtmp)chris@chris-nb:~/computer/wtmp$ ./wtmp.py
Traceback (most recent call last):
File "./wtmp.py", line 3, in <module>
import utmp
ImportError: No module named utmp
(wtmp)chris@chris-注意:~/computer/wtmp$。/wtmp.py
回溯(最近一次呼叫最后一次):
文件“/wtmp.py”,第3行,在
导入utmp
ImportError:没有名为utmp的模块
这是模块问题吗?我做错什么了吗
如果重要的话,操作系统是Ubuntu
以下是重新安装日志:
(wtmp)chris@chris-nb:~/computer/wtmp$ pip install --upgrade --no-deps --force-reinstall utmp
Downloading/unpacking utmp
Downloading utmp-0.4.tar.gz
Running setup.py (path:/home/chris/computer/wtmp/build/utmp/setup.py) egg_info for package utmp
zip_safe flag not set; analyzing archive contents...
flake8.reporter: module references __file__
flake8.tests._test_warnings: module references __file__
flake8.tests.test_integration: module references __file__
Installed /home/chris/computer/wtmp/build/utmp/flake8-2.4.1-py2.7.egg
Searching for six
Reading https://pypi.python.org/simple/six/
Best match: six 1.9.0
Downloading https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz#md5=476881ef4012262dfc8adc645ee786c4
Processing six-1.9.0.tar.gz
Writing /tmp/easy_install-oJJB7w/six-1.9.0/setup.cfg
Running six-1.9.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-oJJB7w/six-1.9.0/egg-dist-tmp-1116oK
no previously-included directories found matching 'documentation/_build'
zip_safe flag not set; analyzing archive contents...
six: module references __path__
Installed /home/chris/computer/wtmp/build/utmp/six-1.9.0-py2.7.egg
Searching for mccabe>=0.2.1,<0.4
Reading https://pypi.python.org/simple/mccabe/
Best match: mccabe 0.3.1
Downloading https://pypi.python.org/packages/source/m/mccabe/mccabe-0.3.1.tar.gz#md5=9a1570c470ff5db678cc0c03d5c0c237
Processing mccabe-0.3.1.tar.gz
Writing /tmp/easy_install-uFdTms/mccabe-0.3.1/setup.cfg
Running mccabe-0.3.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-uFdTms/mccabe-0.3.1/egg-dist-tmp-Q139di
Installed /home/chris/computer/wtmp/build/utmp/mccabe-0.3.1-py2.7.egg
Searching for pep8>=1.5.7,!=1.6.0,!=1.6.1,!=1.6.2
Reading https://pypi.python.org/simple/pep8/
Best match: pep8 1.5.7
Downloading https://pypi.python.org/packages/source/p/pep8/pep8-1.5.7.tar.gz#md5=f6adbdd69365ecca20513c709f9b7c93
Processing pep8-1.5.7.tar.gz
Writing /tmp/easy_install-BdNCrK/pep8-1.5.7/setup.cfg
Running pep8-1.5.7/setup.py -q bdist_egg --dist-dir /tmp/easy_install-BdNCrK/pep8-1.5.7/egg-dist-tmp-rrUWb1
warning: no previously-included files matching '*.pyc' found under directory 'docs'
warning: no previously-included files matching '*.pyo' found under directory 'docs'
warning: no previously-included files matching '*.pyc' found under directory 'testsuite'
warning: no previously-included files matching '*.pyo' found under directory 'testsuite'
no previously-included directories found matching 'docs/_build'
Installed /home/chris/computer/wtmp/build/utmp/pep8-1.5.7-py2.7.egg
Searching for pyflakes>=0.8.1,<0.9
Reading https://pypi.python.org/simple/pyflakes/
Best match: pyflakes 0.8.1
Downloading https://pypi.python.org/packages/source/p/pyflakes/pyflakes-0.8.1.tar.gz#md5=905fe91ad14b912807e8fdc2ac2e2c23
Processing pyflakes-0.8.1.tar.gz
Writing /tmp/easy_install-R5ltqy/pyflakes-0.8.1/setup.cfg
Running pyflakes-0.8.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-R5ltqy/pyflakes-0.8.1/egg-dist-tmp-a8CCFW
zip_safe flag not set; analyzing archive contents...
pyflakes.checker: module references __file__
pyflakes.checker: module references __path__
pyflakes.test.test_api: module references __file__
pyflakes.test.test_undefined_names: module references __file__
pyflakes.test.test_undefined_names: module references __path__
Installed /home/chris/computer/wtmp/build/utmp/pyflakes-0.8.1-py2.7.egg
warning: no files found matching '*.rst' under directory 'docs'
warning: no files found matching '*.py' under directory 'docs'
Installing collected packages: utmp
Found existing installation: utmp 0.4
Uninstalling utmp:
Successfully uninstalled utmp
Running setup.py install for utmp
warning: no files found matching '*.rst' under directory 'docs'
warning: no files found matching '*.py' under directory 'docs'
Installing utmp script to /home/chris/computer/wtmp/bin
Successfully installed utmp
Cleaning up...
(wtmp)chris@chris-注意:~/computer/wtmp$pip安装--升级--无deps--强制重新安装utmp
下载/解包utmp
下载utmp-0.4.tar.gz
运行setup.py(路径:/home/chris/computer/wtmp/build/utmp/setup.py)包utmp的egg\u信息
未设置zip_安全标志;正在分析存档内容。。。
flake8.reporter:模块引用文件__
8.测试。测试警告:模块引用文件__
flake8.tests.test\u集成:模块引用\u文件__
已安装/主页/chris/computer/wtmp/build/utmp/flake8-2.4.1-py2.7.1
寻找六个
阅读https://pypi.python.org/simple/six/
最佳比赛:六场1.9.0
正在下载https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz#md5=476881ef4012262dfc8adc645ee786c4
加工6-1.9.0.tar.gz
正在编写/tmp/easy_install-oJJB7w/six-1.9.0/setup.cfg
运行six-1.9.0/setup.py-q bdist_egg--dist dir/tmp/easy_install-oJJB7w/six-1.9.0/egg-dist-tmp-1116oK
未找到与“documentation/\u build”匹配的以前包含的目录
未设置zip_安全标志;正在分析存档内容。。。
六:模块引用路径__
已安装/home/chris/computer/wtmp/build/utmp/six-1.9.0-py2.7.egg
正在搜索mccabe>=0.2.1,=1.5.7=1.6.0,!=1.6.1,!=1.6.2
阅读https://pypi.python.org/simple/pep8/
最佳匹配:pep8 1.5.7
正在下载https://pypi.python.org/packages/source/p/pep8/pep8-1.5.7.tar.gz#md5=f6adbdd69365ecca20513c709f9b7c93
加工pep8-1.5.7.tar.gz
正在编写/tmp/easy_install-BdNCrK/pep8-1.5.7/setup.cfg
运行pep8-1.5.7/setup.py-q bdist_egg--dist dir/tmp/easy_install-BdNCrK/pep8-1.5.7/egg-dist-tmp-rrUWb1
警告:在目录“docs”下找不到以前包含的与“*.pyc”匹配的文件
警告:在目录“docs”下找不到以前包含的与“*.pyo”匹配的文件
警告:在目录“testsuite”下找不到以前包含的与“*.pyc”匹配的文件
警告:在目录“testsuite”下找不到以前包含的与“*.pyo”匹配的文件
未找到与“docs/\u build”匹配的以前包含的目录
已安装/主页/chris/computer/wtmp/build/utmp/pep8-1.5.7-py2.7.egg
搜索pyflakes>=0.8.1,您可以通过调用pip list
或pip show utmp
来检查它是否安装在您的virualenv中
如果没有,请尝试重新安装:
pip安装--升级--无deps--强制重新安装utmp
并用错误日志扩展您的问题
还要验证,因为它可能不会指向您的virtualenv。刚刚遇到了相同的问题。我通过使用哪个python
找到了问题所在。它告诉我,实际上我有一个别名,它指向一个不同于当前virtualenv
中的python可执行文件。显然,别名比通过source
设置的路径更重要。它似乎已安装:(wtmp)chris@chris-注意:~/computer/wtmp$pip list argparse(1.2.1)enum(0.4.4)pip(1.5.4)setuptools(2.2)utmp(0.4)wsgiref(0.1.2)您是否尝试过重新安装它:pip安装--升级--无deps--强制重新安装utmp
?我已在上面添加了重新安装日志。您是否可以尝试启动python解释器并键入import utmp
。如果这样做有效,问题就出在wtmp.py
脚本中。检查,因为它可能不会指向您的venv。谢谢!我用错了Shebang线!自从我上次使用python和virtualenv已经有一段时间了。是的,别名优先。为什么这与这个问题有关?这是相关的,因为这可能是为什么在virtualenv中找不到Python模块的原因之一。如果有人早点把它贴在这里,我会更快地解决我的问题,因此我想我会在这里添加我的解决方案作为提示。