[英]How to setup PyDev's python interpreter in eclipse using pip within a virtualenv
I want to use pip to install new packages and they say to install pip in a virtualenv . 我想用pip来安装新包,他们说要在virtualenv中安装pip 。 I did that and installed some packages and use them no problem. 我做到了,并安装了一些软件包,并使用它们没有问题。
But I have a problem setting up the simple google app engine helloworld app under PyDev using python2.7. 但是我在使用python2.7在PyDev下设置简单的Google应用程序引擎helloworld应用程序时遇到问题。 I set it up to use C:\\Python27\\env\\Scripts\\python.exe. 我将其设置为使用C:\\ Python27 \\ env \\ Scripts \\ python.exe。 But running it gave an error that it couldn't import pdb . 但是运行它会导致错误, 导致无法导入pdb 。
Running the virtualenv python from the cmd line and calling 'import pdb' gave no errors. 从cmd行运行virtualenv python并调用“ import pdb”不会产生任何错误。 And typing pdb echoed: module 'pdb' from 'C:\\Python27\\lib\\pdb.py' . 然后输入pdb echo: 'C:\\ Python27 \\ lib \\ pdb.py'中的模块'pdb' 。 So from the cmd line, it could find pdb in the root lib dir. 所以从cmd行,它可以在根lib目录中找到pdb。 The debug out from appengine said it was using the virtualenv python. 从appengine进行的调试表明,它使用的是virtualenv python。 I made sure that I had C:\\Python27\\lib in the System PYTHONPATH when setting up the PyDev interpreter, but this did not matter. 在设置PyDev解释器时,我确保系统PYTHONPATH中有C:\\ Python27 \\ lib,但这没关系。 Strange. 奇怪。 (I also have C:\\Python27\\DLLs and C:\\Python27\\lib\\lib-tk). (我也有C:\\ Python27 \\ DLL和C:\\ Python27 \\ lib \\ lib-tk)。
So I tried using the root python exe as the interpreter and it works fine. 所以我尝试使用root python exe作为解释器,它工作正常。 No problem with pdb, so my code is correct. pdb没问题,所以我的代码是正确的。 But now it can't find the modules I added using pip in the virtualenv. 但是现在它找不到在virtualenv中使用pip添加的模块。
It seems there are 3 options for setting this up correctly: 似乎有3个选项可以正确设置此设置:
I hope someone who has gone through this before can give some advice as to the best way to proceed with the least amount of problems later. 我希望以前经历过此问题的人可以就以后处理最少问题的最佳方法提供一些建议。
I did some research on the google-appengine-python group and they say to go with option 3: Don't listen to the pip advice when using it with google appengine. 我对google-appengine-python组进行了一些研究,他们说选择3:当使用google appengine时不要听pip建议。 appengine does not play nice with virtualenv. appengine与virtualenv搭配不好。
Refs: 参考文献:
Appengine with virtualenv 印度与virtualenv
Strange imports (and WARNINGs) in development server 开发服务器中的奇怪导入(和警告)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.