链接wxpython来运行drpython

发布于 2024-12-29 02:40:00 字数 1586 浏览 0 评论 0原文

我想运行 drpython,但它找不到我安装的 wxpython 库:

C:\Users\Niklas\Desktop\DrPython>python drpython.pyw
Traceback (most recent call last):
  File "drpython.pyw", line 35, in <module>
    import drpython
  File "C:\Users\Niklas\Desktop\DrPython\drpython.py", line 48, in <module>
    import wx, wx.stc
ImportError: No module named wx

我该怎么解决这个问题?我使用 Windows 7,在 Ubuntu 上这是有效的。 我安装了wx,但python解释器找不到wx模块:

Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named wx
>>>

我的路径是

C:\Users\Niklas>echo %PATH%
C:\Program Files (x86)\ActiveState Komodo IDE 6\;C:\Windows\system32;C:\Windows;
C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program
Files (x86)\Hewlett-Packard\HP ProtectTools Security Manager\Bin\;C:\Program Fil
es (x86)\Intel\Services\IPT\;C:\Program Files\Mercurial\;C:\Program Files\Tortoi
seHg\;C:\python27\;C:\Program Files (x86)\Google\google_appengine\;C:\python27\L
ib\site-packages;C:\python27

我的sys.path是

>>> import sys
>>> sys.path
['', 'C:\\Windows\\system32\\python27.zip', 'C:\\python27\\DLLs', 'C:\\python27\
\lib', 'C:\\python27\\lib\\plat-win', 'C:\\python27\\lib\\lib-tk', 'C:\\python27
', 'C:\\python27\\lib\\site-packages']
>>>

I want to run drpython but it can't find the wxpython library that I installed:

C:\Users\Niklas\Desktop\DrPython>python drpython.pyw
Traceback (most recent call last):
  File "drpython.pyw", line 35, in <module>
    import drpython
  File "C:\Users\Niklas\Desktop\DrPython\drpython.py", line 48, in <module>
    import wx, wx.stc
ImportError: No module named wx

What can I do to resolve this? I use Windows 7 and on Ubuntu this is working.
I installed wx but the python interpreter can't find the wx module:

Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named wx
>>>

My path is

C:\Users\Niklas>echo %PATH%
C:\Program Files (x86)\ActiveState Komodo IDE 6\;C:\Windows\system32;C:\Windows;
C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program
Files (x86)\Hewlett-Packard\HP ProtectTools Security Manager\Bin\;C:\Program Fil
es (x86)\Intel\Services\IPT\;C:\Program Files\Mercurial\;C:\Program Files\Tortoi
seHg\;C:\python27\;C:\Program Files (x86)\Google\google_appengine\;C:\python27\L
ib\site-packages;C:\python27

My sys.path is

>>> import sys
>>> sys.path
['', 'C:\\Windows\\system32\\python27.zip', 'C:\\python27\\DLLs', 'C:\\python27\
\lib', 'C:\\python27\\lib\\plat-win', 'C:\\python27\\lib\\lib-tk', 'C:\\python27
', 'C:\\python27\\lib\\site-packages']
>>>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晚雾 2025-01-05 02:40:00

这里相关的是 sys.path - 而不是环境 %PATH%。

例如:

In [45]: sys.path
Out[45]: 
['',
 '/usr/bin',
 '/usr/lib/python2.7/site-packages/django_debug_toolbar-0.9.1-py2.7.egg',
 '/usr/lib/python27.zip',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7/site-packages',
 '/usr/lib/python2.7/site-packages/Numeric',
 '/usr/lib/python2.7/site-packages/PIL',
 '/usr/lib/python2.7/site-packages/gst-0.10',
 '/usr/lib/python2.7/site-packages/gtk-2.0',
 '/usr/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info',
 '/usr/lib/python2.7/site-packages/wx-2.8-gtk2-unicode',
 '/usr/lib/python2.7/site-packages/IPython/Extensions',
 u'/home/alf/.ipython']

如果您想从环境中影响 sys.path,则相关变量是 %PYTHONPATH%。

您还可以导入一个给定完整路径的模块 - 但它变得更棘手 - 请参阅

What's relevant here is sys.path - not the environment %PATH%.

E.g.:

In [45]: sys.path
Out[45]: 
['',
 '/usr/bin',
 '/usr/lib/python2.7/site-packages/django_debug_toolbar-0.9.1-py2.7.egg',
 '/usr/lib/python27.zip',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7/site-packages',
 '/usr/lib/python2.7/site-packages/Numeric',
 '/usr/lib/python2.7/site-packages/PIL',
 '/usr/lib/python2.7/site-packages/gst-0.10',
 '/usr/lib/python2.7/site-packages/gtk-2.0',
 '/usr/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info',
 '/usr/lib/python2.7/site-packages/wx-2.8-gtk2-unicode',
 '/usr/lib/python2.7/site-packages/IPython/Extensions',
 u'/home/alf/.ipython']

If you want to influence sys.path from the environment, ther relevant variable is %PYTHONPATH%.

You can also import a module given it's full path - but it gets trickier - see this thread

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文