0
我想導入枕頭模塊。但我必須將其安裝到正在使用它的腳本的文件夾中。 我試圖設置一個搜索路徑並導入:Python:如何將python模塊安裝到某個文件夾並導入它
sWorkDir = os.path.dirname(os.path.realpath(__file__))
print (sWorkDir)
sys.path.append(sWorkDir+"\\PIL_LOC")
sys.path.append(sWorkDir+"\\PIL_LOC\PIL")
import Image
不幸的是,我得到一個
from . import VERSION, PILLOW_VERSION, _plugins
ImportError: attempted relative import with no known parent package
爲什麼你不能讓它在默認目錄安裝(站點程序包)和從那裏使用它?我在這裏錯過了什麼嗎? – tom
甚至更好,使用virtualenv。 –
無法進一步安裝模塊 – dgrat