我想寫一個小應用程序來轉換一些圖像。 我認爲必須使用Image.open()
,所以我必須導入Image
模塊。對?如何在PIL/Pillow的窗口下導入Python3.5中的圖像
如果是這樣,這裏是我的問題。我已閱讀other questions like this,但他們中的任何人都爲我工作。我想:
import Image
=>ImportError: cannot import name 'VERSION'
from PIL import Image
=>ImportError: cannot import name 'VERSION'
from Pillow import Image
=>ImportError: No module named 'Pillow'
在documentation我讀:
Pillow and PIL cannot co-exist in the same environment. Before installing Pillow, please uninstall PIL.
Pillow >= 1.0 no longer supports 「import Image」. Please use 「from PIL import Image」 instead.
在我的虛擬環境我已經PIL和枕頭d但是pip list
只給了枕頭(3.1.0)所以,即使是讀other answers,我試着用pip卸載PIL但是找不到PIL,所以我只是刪除目錄PIL並安裝了Pillow-PIL(現在出現在pip list
這裏面的目錄Pillow_PIL
我venv\Lib\site-packages\
)現在:
import Image
=>ImportError: No module named 'PIL'
from PIL import Image
=>ImportError: No module named 'PIL'
from Pillow import Image
=>ImportError: No module named 'Pillow'
from Pillow-PIL import Image
=>SyntaxError: invalid syntax
(減號)
from Pillow_PIL import Image
=>ImportError: No module named 'Pillow_PIL'
apt-get install python-imaging
=>"apt-get"
命令不明(我的意譯)
所以,現在怎麼辦?
編輯:完整的錯誤是
Traceback (most recent call last):
File "prova.py", line 1, in <module>
import Image
File "D:\Python\Envs\possedimenti\lib\site-packages\Image.py", line 1, in <mod
ule>
from PIL.Image import *
File "D:\Python\Envs\possedimenti\lib\site-packages\PIL\Image.py", line 29, in
<module>
from PIL import VERSION, PILLOW_VERSION, _plugins
ImportError: cannot import name 'VERSION'
什麼是操作系統?視窗? Linux呢?什麼是完整的錯誤(之前「無法導入名稱版本」)? – Artyer
操作系統是Windows7。編輯主題 – fabio