2016-03-16 62 views
0

我無法使用枕頭模塊,但我不確定爲什麼。無法從枕頭套件導入

我正在使用一個包含python(2.7)scripter的軟件。所以我必須手動安裝Pillow軟件包 - 只需將文件夾複製到sys.path中顯示的路徑之一。現在的路徑是:

mySoftware\Python27\Pillow 

和我所試圖做的是:

from Pillow.PIL import Image 

所以,它找到Image.py,但在它,它不知道PIL:

>>> from PIL import VERSION, PILLOW_VERSION, _plugins 
ImportError: No module named PIL 
>>> from Pillow.PIL import Image 
Traceback (most recent call last): 
    File "<string>", line 1, in <module> 
    File "C:\Program Files\Sim4Life_v2.2.2.904\Python27\Pillow\PIL\Image.py", line 29, in <module> 

(枕頭沒有一個__init__.py文件。不知道是否應該有。)

我怎樣才能把它找PIL?

+0

我試圖修正格式,但它會更好,你複製的錯誤的完整記錄問題 – flaschbier

+1

爲什麼你手動安裝而不是使用pip? –

+0

Pillow只需從'PIL import image'輸入即可,因爲Pillow需要能夠從本身內部導入模塊,也許可以參見http://stackoverflow.com/questions/20017319/installing-pillow-and-pil用自定義文件夾正確安裝枕頭。 –

回答

0

如果您想在不同的地方使用python,而不是在主安裝文件夾中,則應該使用virtualenv,而不是手動複製。 如果你想要做你的方式,嘗試添加路徑庫複製到sys.path這樣

import os 
import sys 
sys.path.append(os.path.abspath('path/to/copied/libs')) 
+0

感謝您的幫助,但它沒有奏效。最後我做了正常的安裝,我用easy_install。 – hadasara