模块导入期间IDLE/PythonWin之间的不一致 [英] Inconsistency between IDLE/PythonWin during module imports

查看:264
本文介绍了模块导入期间IDLE/PythonWin之间的不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在IDLE/PythonWin甚至Aptana Studio 3之间摸索,试图获得有关导入模块的一致性.我最近使用的模块是来自wxPython的wx和arcpy模块. IDLE将允许我导入arcpy,但不能导入wx. PythonWin将允许我导入wx,但不能导入arcpy.

I have been fumbling around between IDLE/PythonWin and even Aptana Studio 3 trying to get some consistency regarding importing modules. The modules I have been using lately are wx from wxPython and the arcpy module. IDLE will let me import arcpy, but not wx. PythonWin will let me import wx, but not arcpy.

当我在IDLE中执行sys.executable时,我得到"C:\ Python27 \ ArcGIS10.1 \ Lib \ site-packages \ pythonwin \ Pythonwin.exe"

When I do sys.executable in IDLE I get "C:\Python27\ArcGIS10.1\Lib\site-packages\pythonwin\Pythonwin.exe"

当我在PythonWin中执行sys.executable时,我得到"C:\ Python27 \ pythonw.exe"

When I do sys.executable in PythonWin I get "C:\Python27\pythonw.exe"

另外,我想知道我是否使用不同的解释器,如何将它们全部设置为同一解释器,以及使用哪个解释器.

Additionally, I am wondering if I am using different interpreters, how to set them all to the same one, and which one to use.

我已经学习和使用Python半年多了,而我真的很想控制这些问题.

I have been learning and using Python for a little over half a year now and am at the point where I would really like to have these kinds of issues under control.

几年之后的课程:使用pycharm并让您的环境与众不同!大声笑

推荐答案

问题是ArcGIS附带了与软件捆绑在一起的特定Python,并且您已将正态发行版安装到"C:\ Python27 \"中.我会尝试删除后者并重新安装wxPython.我想您所说的这个IDLE实际上是嵌入在ArcGIS中的,而不是普通的IDLE.

The problem is that ArcGIS comes with its own specific Python bundled with the software and you have installed a normal distribution into "C:\Python27\". I would try removing the latter and reinstalling wxPython. I'm guessing this IDLE of which you speak is actually embedded in ArcGIS rather than being the normal IDLE.

更清楚地说,当您最初安装wx时,它在"C:\ Python27 \"中看到了Python,并将其安装在该位置.如果无法将wx安装到GIS位置,则可以通过从C:\ Python27 \复制wx文件夹并将其放入ArcGIS中来伪造它.它们都应该位于"C:\ Python27 \ Lib \ site-packages \ wx-2.9.3-msw"(取决于版本)中,并且还有一个wx.pth文件,您需要从"C"复制:\ Python27 \ Lib \ site-packages"移至GIS目录中的相同基本位置.

To be more clear, when you originally installed wx, it saw the Python in "C:\Python27\" and installed in that location. If you can't get wx to install to the GIS location, there may be a way to fake it by just copying the wx folder from C:\Python27\ and putting it in ArcGIS. They should both be in something like "C:\Python27\Lib\site-packages\wx-2.9.3-msw" (depending on version) and there's also a wx.pth file you'll need to copy from ""C:\Python27\Lib\site-packages" to the same basic location in the GIS directory.

我还找到了以下链接,可能会解决您的问题:

I also found the following links that might address your issue:

  • http://www.scoop.it/t/arcpy/p/1759717424/custom-wxpython-gui-s-an-approach-for-arcgis-10-1-arcgis-resource-center
  • http://forums.arcgis.com/threads/41809-wxPython-hooked-to-arcmap
  • wxPython and ARCGIS

听起来您必须添加wxPython作为加载项.

It sounds like you have to add wxPython as an add-in.

这篇关于模块导入期间IDLE/PythonWin之间的不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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