简体   繁体   English

如何告诉Aptana Studio使用Python virtualenv?

[英]How do I tell Aptana Studio to use Python virtualenv?

I did some searches on this topic and the solutions didn't work for me. 我对这个主题做了一些搜索,解决方案对我不起作用。 I am running both a Linux (Ubuntu) environment and Windows. 我正在运行Linux(Ubuntu)环境和Windows。 My system is Windows 8.1 but I have virtualbox with Ubuntu on that. 我的系统是Windows 8.1,但我有Ubuntu的虚拟机。
Starting with Windows... I created a venv directory off the root of the e drive. 从Windows开始......我在电子驱动器的根目录下创建了一个venv目录。 Created a project folder and then ran the activate command, which is in the venv>Scripts directory. 创建一个项目文件夹,然后运行activate命令,该命令位于venv> Scripts目录中。 So, after activating that (note, I had installed virtualenv already)... so after activating that I then changed into the folder with my module and it ran fine, with the shebang, I didn't even have to type python in front of my filename. 因此,在激活之后(注意,我已经安装了virtualenv)...所以在激活后我然后用我的模块改成了文件夹并且它运行正常,与shebang,我甚至不必在前面键入python我的文件名。 However, in Aptana Studio, it cannot find the module I installed with pip. 但是,在Aptana Studio中,找不到我用pip安装的模块。 So, it doesn't work. 所以,它不起作用。 In an earlier post it was recommended that one choose a different interpreter and browse to the env and select that. 在之前的帖子中,建议选择不同的解释器并浏览到env并选择它。

So, how does one get this installed and working with an IDE like Eclipse and Aptana Studio? 那么,如何安装和使用Eclipse和Aptana Studio等IDE?

I am having problems on Ubuntu. 我在Ubuntu上遇到了问题。 The instructions I found had me using package installer to install virtualenv, pip and a few other tools that package these. 我发现的说明让我使用软件包安装程序来安装virtualenv,pip和其他一些打包这些的工具。 The problem is that on Ubuntu the default version of python is 2.7.x. 问题是在Ubuntu上,python的默认版本是2.7.x. I need 3.3 or 3.x. 我需要3.3或3.x. So, can someone point me in the direction of how to setup virtual environments for the 2.7.x branch of python and the 3.x branch. 所以,有人能指出我如何为python的2.7.x分支和3.x分支设置虚拟环境的方向。

Also, how does one tell the IDE (Eclipse or Aptana Studio) to use the virtualenv? 另外,如何告诉IDE(Eclipse或Aptana Studio)使用virtualenv? Thanks, Bruce 谢谢,布鲁斯

Configure Aptana Studio's python interpreter( you can configure more than one) 配置Aptana Studio的python解释器(你可以配置多个)

In aptana, Window -> Preferences -> Interpreter Python and create a New interpreter. 在aptana, Window - > Preferences - > Interpreter Python中创建一个新的解释器。 Select the python executable from the virtual environment (in windows it is python.exe which resides in Scripts subfoler of the virtualenv,where as in ubuntu python is under bin subfolder) . 从虚拟环境中选择python可执行文件(在windows中它是python.exe ,它驻留在virtualenv的Scripts子文件夹中,其中ubuntu python位于bin子文件夹下)。 Now Aptana will show a list of directories to add also remember to check C:\\Python27\\Lib or Ubuntu conterpart. 现在Aptana将显示要添加的目录列表,记得检查C:\\ Python27 \\ Lib或Ubuntu conterpart。

Now on creating use this interpreter. 现在开始创建使用这个解释器。

Or if to use with existing project 或者如果要与现有项目一起使用

Step 1.Take project properties(File -> Properties OR By right clicking on Project). 步骤1.获取项目属性(文件 - >属性或右键单击项目)。

Step 2.From PyDev Interpreter/Grammer select the interpreter you configured above. 步骤2.从PyDev Interpreter / Grammer中选择您在上面配置的解释器。

Edit : 编辑:

In this way you can even configure both python 3 and python 2 for Aptana. 通过这种方式,您甚至可以为Aptana配置python 3和python 2。 You have to configure an interpreter for each python 3 and python 2. Then follow steps above to select the interpreter. 你必须为每个python 3和python 2配置一个解释器。然后按照上面的步骤选择解释器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM