[英]CentOS 7 Python ImportError: cannot import name QtWebkit even though it's in my PyQt4 site-packages directory
[英]Python: I can't import a module even though it's in site-packages
我正在遵循教程“Think Python”,我應該安裝名為swampy的軟件包。 我正在運行python 2.7.3雖然我也安裝了python 3。 我解壓縮包並將其放在site-packages中:
C:\\ Python27 \\ LIB \\站點包\\沼澤-2.1.1
C:\\ Python31 \\ LIB \\站點包\\沼澤-2.1.1
但是當我嘗試從python中導入一個模塊時:
import swampy.TurtleWorld
我只是沒有名為swampy.TurtleWorld的模塊。
如果有人可以幫助我,我真的很感激,如果有幫助的話,這里有一個鏈接到課程:
http://www.greenteapress.com/thinkpython/html/thinkpython005.html
我解壓縮包並將其放在site-packages中:
不,這是“安裝”包的錯誤方式。 Python包附帶了一個setup.py
腳本,應該用它來安裝它們。 簡單地說:
python setup.py install
並且該模塊將正確安裝在您正在使用的python解釋器的site-packages中。 如果你想為特定的python版本安裝它,請使用python2
/ python3
而不是python
。
如果其他人在Windows上遇到此問題,我只是將我的sites-package目錄添加到我的PATH變量中,它就像任何正常的模塊導入一樣。
C:\Python34\Lib\site-packages
希望能幫助到你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.