Inconsistency between IDLE/PythonWin during module imports

南楼画角 提交于 2020-01-16 19:13:03

问题


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.

When I do sys.executable in IDLE I get "C:\Python27\ArcGIS10.1\Lib\site-packages\pythonwin\Pythonwin.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.

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.

edit: lesson learned years later: use pycharm and let it keep your environments separate for you! lol


回答1:


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.

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.

EDIT: 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

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



来源:https://stackoverflow.com/questions/16184829/inconsistency-between-idle-pythonwin-during-module-imports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!