Aptana Python stdlib问题与virtualenv [英] Aptana Python stdlib issue with virtualenv

查看:113
本文介绍了Aptana Python stdlib问题与virtualenv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

     最近,我开始使用vim作为带有virtualenv设置的文本编辑器来进行项目开发.我从GitHub在此virtualenv上安装了一些API.最终,项目变得比vim可以处理的要大一些,因此我不得不将项目移至IDE.
     我选择了Aptana Studio3.启动Aptana时,我将项目目录指向创建用于容纳项目的virtualenv文件夹.然后,我将解释器指向App/bin(从virtualenv创建)/python2.7中的Python可执行文件.当我开始重新编写代码以确保正确映射所有内容时,我能够导入已经安装好的API. CherryPy顺利完成,但是导入一个我认为是stdlib--urlparse一部分的模块时遇到了问题.起初,我以为我的python解释器是2.7.1而不是2.7.5(我在2.7.5节中找到了文档,没有选择查看2.7.1的选项),但是我的终端使用的是2.7.1和能够导入模块而没有任何错误(我正在使用OSX,Mountain Lion).当我激活virtualenv并运行python解释器时,我也能够导入模块.但是,当我将"from urlparse import parse_qsl"插入Aptana时,出现错误:"Unresolved_import:parse_qsl".

   我是否应该将此指向其他解释器?如果是,是否需要重新安装在新解释器中使用过的API模块?

      I recently started working on a project using just vim as my text editor with a virtualenv setup. I installed a few API's on this virtualenv from GitHub. Eventually, the project got a little bigger than vim could handle so I had to move the project to an IDE.
      I chose Aptana Studio 3. When I started up Aptana, I pointed the project directory to the virtualenv folder that I had created to house my project. I then pointed the interpreter at the Python executable in App/bin (created from virtualenv)/python2.7. When I started reworking the code to make sure I had everything mapped correctly, I was able to import the API's that I had installed just fine. CherryPy came through with no problems, but I've been having an issue with importing a module that I believe is part of the stdlib--urlparse. At first, I thought it was that my python interpreter was 2.7.1 rather than 2.7.5 (I found the documentation in the 2.7.5 section with no option to review 2.7.1), but my terminal is using 2.7.1 and is able to import the module without any errors (I'm using OSX, Mountain Lion). I am also able to import the module when I activate the virtualenv and run my python interpreter. But when I plug "from urlparse import parse_qsl" into Aptana, I'm getting an error: "Unresolved_import: parse_qsl".

    Should I have pointed this at a different interpreter and, if so, will I need to reinstall the API modules I had been working with in the new interpreter?

推荐答案

   更新:我终于结束了重新启动项目.事实证明,当您选择virtualenv解释器时,并不是所有标准的Python工具都被选中.从列表中选择了所有python工具之后(选择了解释器之后),我就可以访问整个标准库.

   不要只是将模块导入到您的项目中.许多stdlib模块是相互依赖的,并且import函数只会将模块导入到您的主项目目录中,而不是库中!

    Update: I finally ended up restarting the project. It turns out that not all of the standard Python tools are selected when you select the virtualenv interpreter. After I selected all of the python tools from the list (just after choosing the interpreter), I was able to get access to the entire standard library.

    Do NOT just import the modules into your project. Many of the stdlib modules are interdependent and the import function will only import a module into your main project directory, not a libary!

这篇关于Aptana Python stdlib问题与virtualenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆