2014-02-23 139 views
0

我一直在使用wxPython3.0-win32-3.0.0.0-py27.exe安裝的wxPython(推薦;次重新安裝一堆,以確保不會幫助)。在安裝結束時,它詢問是否應該編譯wxPythonpy文件。我選擇編譯;沒有錯誤。的Python/wxPython的:導入錯誤:沒有模塊名爲lib.buttons

我有import wximport wx.lib.buttons as buttons在我的py文件(我的代碼)。

print wx說:<module 'wx' from 'C:\Python27\lib\site-packages\pyinstaller-2.1-py2.7.egg\wx\__init__.pyc'>(?爲什麼PyInstaller我重新安裝wxPython並選擇它成爲默認wx包)。

print sys.executable sys:C:\Python27\python.exe

print sys.path說:

['C:\\zone_workspace\\cef\\cefpython-tut\\examples', 
'C:\\Python27\\lib\\site-packages\\pyinstaller-2.1-py2.7.egg', 
'C:\\Python27\\lib\\site-packages\\distribute-0.7.3-py2.7.egg', 
'C:\\Python\\Lib\\site-packages\\cefpython3', 
'C:\\wxPython-Docs-and-Demos', 
'C:\\zone_workspace\\cef\\cefpython-tut\\examples', 
'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', 
'C:\\Python27\\lib\\site-packages\\win32', 
'C:\\Python27\\lib\\site-packages\\win32\\lib', 
'C:\\Python27\\lib\\site-packages\\Pythonwin', 
'c:\\python27\\lib\\site-packages', 
'C:\\Python27\\lib\\site-packages\\wx-3.0-msw'] 

正如我們可以看到'C:\\Python27\\lib\\site-packages\\wx-3.0-msw'sys.path

而且wx.pth文件在C:\Python27\Lib\site-packages路徑中,僅包含wx-3.0-msw;存在的目錄的名稱幷包含wx包。

即使PyCharm已經識別出wx包裝,並且它的pyfu完美。

奇怪的是,它識別wx但不是wx.lib.buttons(在import wx.lib.buttons as buttons)。

這是怎麼回事?

+0

您需要修復您的路徑以將pyinstaller關閉......或者至少在站點包目錄後,對於我而言,wx .__ file__是'C:\\ Python26 \\ lib \\ site-packages \\ wx- 2.8-msw-unicode \\ wx \\ __ init __。pyc' –

+0

如何刪除或覆蓋PyInstaller wx路徑? (不好意思,我還不是Python開發者)。 –

回答

0

在我的情況下有兩個問題:首先有C:\Python27\Lib\site-packages\PyInstaller-2.1-py2.7.egg\wx,我已更名爲C:\Python27\Lib\site-packages\PyInstaller-2.1-py2.7.egg\wx_renamed,第二個是C:\Python\Lib\site-packages\cefpython3\wx,我已將其更名爲C:\Python\Lib\site-packages\cefpython3\wx_renamed。這兩個目錄都包含wx的幫助代碼,而不是wx本身。

希望這可以幫助其他Python新手。

相關問題