[英]Can't find modules installed via virtualenv on windows
I'm running virtualenv on Windows 7 and I created a virtual environment for python 2.7 and installed some modules but I can't seem to import it. 我在Windows 7上运行virtualenv,并为python 2.7创建了一个虚拟环境并安装了一些模块,但似乎无法导入它。
1) venv\\scripts\\activate 1)venv \\ scripts \\ activate
2) pip2 install requests 2)pip2安装请求
(I the following message: get Requirement already satisfied (use --upgrade to upgrade): requests in c:\users\dan\desktop\python\bulkphotos\venv\lib\site-packages)
3) when I try to import this on the interactive shell, I get the following error 3)当我尝试在交互式外壳上导入它时,出现以下错误
(venv) C:\Users\Dan\Desktop\Python\bulkphotos>py
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named requests
4) I've tried searching SO but the other answers seem to be applicable for a mac (eg accidentally installing via sudo). 4)我尝试搜索SO,但其他答案似乎适用于Mac(例如,通过sudo意外安装)。 When I do pip2 list, the module is present, so I don't understand why I can't access it. 当我执行pip2列表时,该模块存在,所以我不明白为什么我无法访问它。
(venv) C:\Users\Dan\Desktop\Python\bulkphotos>pip2 list
google-api-python-client (1.4.1)
httplib2 (0.9.1)
oauth2client (1.4.12)
pip (7.1.0)
pyasn1 (0.1.8)
pyasn1-modules (0.0.7)
requests (2.7.0)
rsa (3.2)
setuptools (18.0.1)
simplejson (3.8.0)
six (1.9.0)
uritemplate (0.6)
wheel (0.24.0)
(venv) C:\Users\Dan\Desktop\Python\bulkphotos>pip2 show requests
---
Metadata-Version: 2.0
Name: requests
Version: 2.7.0
Summary: Python HTTP for Humans.
Home-page: http://python-requests.org
Author: Kenneth Reitz
Author-email: me@kennethreitz.com
License: Apache 2.0
Location: c:\users\dan\desktop\python\bulkphotos\venv\lib\site-packages
Requires:
(venv) C:\Users\Dan\Desktop\Python\bulkphotos>
Does anyone know how to solve this problem? 有谁知道如何解决这个问题?
EDIT The results of running sys.path on the interactive shell 编辑在交互式shell上运行sys.path的结果
['', 'C:\\windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages']
The results of running where py and where python 在where py和where python上运行的结果
(venv) C:\Users\Dan\Desktop\Python\bulkphotos>where py
C:\Windows\py.exe
(venv) C:\Users\Dan\Desktop\Python\bulkphotos>where python
C:\Users\Dan\Desktop\Python\bulkphotos\venv\Scripts\python.exe
C:\Python27\python.exe
C:\Python34\python.exe
I dont know why these packages are not imported, 我不知道为什么这些包裹没有被进口,
But you can debug it by viewing your pythonpath using, 但是您可以通过使用以下命令查看pythonpath来调试它:
python -c "import sys; print sys.path"
You can append optional path to sys.path
. 您可以将可选路径附加到sys.path
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.