蟒蛇 +姜戈 +虚拟环境视窗
我在安装 python + virtualenv + django 时遇到一些问题,需要帮助。
系统:Windows 7、64b
我做什么? 1) 安装Python 2.7.2 (32位) 2)安装SetupTools(32位) 3) 安装 VirtualEnv
E:\APPZ\Console2>C:\Python27\Scripts\easy_install.exe virtualenv
4) 创建 virtualenv:
E:\APPZ\Console2>virtualenv E:\CODE\wamp\www\AMBIENTES\env
5) 好的,现在我创建了一个“.bat”来使用我的 env 并将其放入 C:\Windows 中。
C:\Windows\python.bat
cmd.exe /k E:\CODE\wamp\www\AMBIENTES\env\Scripts\activate.bat
到目前为止一切顺利 现在我执行了 python.bat 并安装了 django:
E:\APPZ\Console2>python
E:\APPZ\Console2>cmd.exe /k E:\CODE\wamp\www\AMBIENTES\env\Scripts\activate.bat
(env) E:\APPZ\Console2>cd E:\CODE\wamp\www\AMBIENTES\Django-1.2.7
(env) E:\CODE\wamp\www\AMBIENTES\Django-1.2.7>python setup.py install
django installed (1.2.7) successfully.
现在,问题是:
(env) E:\CODE\wamp\www\AMBIENTES\Django-1.2.7>E:\CODE\wamp\www\AMBIENTES\env\Scripts\django-admin.py --version
Traceback (most recent call last):
File "E:\CODE\wamp\www\AMBIENTES\env\Scripts\django-admin.py", line 2, in <module>
from django.core import management
ImportError: No module named django.core
(env) E:\CODE\wamp\www\AMBIENTES\Django-1.2.7>
-
有谁知道我能做什么?
I had some problem on installing python + virtualenv + django and need help.
System: Windows 7, 64b
What i do?
1) Installed Python 2.7.2 (32bits)
2) Installed SetupTools (32 bits)
3) Installed VirtualEnv
E:\APPZ\Console2>C:\Python27\Scripts\easy_install.exe virtualenv
4) Created virtualenv:
E:\APPZ\Console2>virtualenv E:\CODE\wamp\www\AMBIENTES\env
5) Fine, now I created a ".bat" to use my env and put then in C:\Windows.
C:\Windows\python.bat
cmd.exe /k E:\CODE\wamp\www\AMBIENTES\env\Scripts\activate.bat
So far so good
Now I executed the python.bat and installed django:
E:\APPZ\Console2>python
E:\APPZ\Console2>cmd.exe /k E:\CODE\wamp\www\AMBIENTES\env\Scripts\activate.bat
(env) E:\APPZ\Console2>cd E:\CODE\wamp\www\AMBIENTES\Django-1.2.7
(env) E:\CODE\wamp\www\AMBIENTES\Django-1.2.7>python setup.py install
django installed (1.2.7) successfully.
And now, the problem:
(env) E:\CODE\wamp\www\AMBIENTES\Django-1.2.7>E:\CODE\wamp\www\AMBIENTES\env\Scripts\django-admin.py --version
Traceback (most recent call last):
File "E:\CODE\wamp\www\AMBIENTES\env\Scripts\django-admin.py", line 2, in <module>
from django.core import management
ImportError: No module named django.core
(env) E:\CODE\wamp\www\AMBIENTES\Django-1.2.7>
-
Does anyone know what I can do about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这个问题已经很老了,对于作者来说可能不再实际了。但就它出现在谷歌顶部而言,我会留下对我有帮助的答案。
基本上,正确的答案是发布类似的问题。
严格来说,当您执行 django-admin.py --version 时,会调用错误的 Python 安装。为了检查您在这种情况下使用的 Python,请在“命令行”中输入
ftype Python.File
。如果不是 virtualenv,那么您可以重新关联默认的 Python:ftype Python.File="E:\CODE\wamp\www\AMBIENTES\env\Scripts\python.exe" "%1" %*
或者取消文件关联(从cmd.exe):
重新关联
.py
扩展程序后,您应该指定执行Python文件的完整路径:E:\CODE\ wamp\www\AMBIENTES\env\Scripts\python.exe E:\CODE\wamp\www\AMBIENTES\env\Scripts\django-admin.py --version
或者,如果您愿意,您可以编辑 virtualenv 的
activate.bat
来放置特定的.py
关联,使用上面提到的assoc
和ftype
命令行实用程序。I know this question is old and maybe not actual anymore for author. But as far as it appears at Google's top, I would leave the answer that helped me.
Basically the correct answer is posted for the similar question.
Strictly speaking the wrong Python installation is called when you execute
django-admin.py --version
. in order to check which Python you use in the case, typeftype Python.File
in "command line". If it's not the virtualenv's one, then you could reassociate the default Python:ftype Python.File="E:\CODE\wamp\www\AMBIENTES\env\Scripts\python.exe" "%1" %*
Or unset the file association (from cmd.exe):
After you reassociate the
.py
extension program, you should specify full path to execute Python files:E:\CODE\wamp\www\AMBIENTES\env\Scripts\python.exe E:\CODE\wamp\www\AMBIENTES\env\Scripts\django-admin.py --version
Or if you want, you could edit virtualenv's
activate.bat
to put specific.py
association, usingassoc
andftype
command line utils, mentioned above.我相信您的问题是,将 python setup.py install 与 Django 源一起使用是将 Django 安装在您的主 site-packages/dist-packages 路径中,而不是您的虚拟环境中。
相反,使用pip或easy_install:
如果你不能直接从PyPi(企业防火墙等)下载,你可以通过稍微修改命令来使用你已有的源:(
转换后的Windows路径可能需要一些调整。我认为这是对的,但已经有一段时间了)
I believe your problem is that using
python setup.py install
with the Django source is installing Django in your primary site-packages/dist-packages path instead of that of your virtual environment.Instead, use pip or easy_install:
If you can't directly download from PyPi (corporate firewall, etc.) you can use the source you already have by modifying the command slightly:
(Converted Windows path may need some tweaking. I think that's right, but it's been awhile)