[英]no module found PIL but it is installed and up2date
我試圖在Mac OS X上下載有刮痕的圖像,它返回以下錯誤消息:
ModuleNotFoundError: No module named 'PIL'
$ pip install image
Requirement already satisfied: image in /Library/Python/2.7/site-packages (1.5.27)
Requirement already satisfied: django in /Library/Python/2.7/site-packages (from image) (1.11.16)
Requirement already satisfied: pillow in /Library/Python/2.7/site-packages (from image) (5.3.0)
Requirement already satisfied: pytz in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from django->image) (2013.7)
讓我們嘗試安裝映像包:
$ pip install image
Reqfuirement already satisfied: image in /Library/Python/2.7/site-packages (1.5.27)
Requirement already satisfied: django in /Library/Python/2.7/site-packages (from image) (1.11.16)
Requirement already satisfied: pillow in /Library/Python/2.7/site-packages (from image) (5.3.0)
Requirement already satisfied: pytz in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from django->image) (2013.7)
更新點子?
pip install --upgrade pip
Requirement already up-to-date: pip in /Library/Python/2.7/site-packages/pip-18.1-py2.7.egg (18.1)
通過自制軟件安裝Python ist
通過sudo進行PIP: sudo pip install image
還嘗試了:
easy_install pip
Password:
Searching for pip
Best match: pip 18.1
Processing pip-18.1-py2.7.egg
pip 18.1 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin
Using /Library/Python/2.7/site-packages/pip-18.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
和:
brew unlink python && brew link python
更多信息:
File "/usr/local/lib/python3.7/site-packages/scrapy/pipelines/images.py", line 15, in <module>
from PIL import Image
ModuleNotFoundError: No module named 'PIL'
MBP:bid user$ type python
python is hashed (/usr/local/opt/python/libexec/bin/python)
MBP:bid user$ /usr/local/opt/python/libexec/bin/pip show pip
Name: pip
Version: 18.1
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: pypa-dev@groups.google.com
License: MIT
Location: /usr/local/lib/python3.7/site-packages
Requires:
Required-by:
任何想法如何解決?
您要使用哪個版本的Python? 您似乎聲稱您是通過自制軟件安裝的Python,但是您使用的是Apple在/usr/bin/python
提供的Python 2.7,這就是為什么pip安裝在/Library/Python/2.7
。
如果要使用自制 Python和pip
,則需要運行/usr/local/opt/python/libexec/bin/python
。 如果運行,則可以查看所有這些信息:
brew info python
通常,在/anywhere/LOCAL/anywhere
中查找或安裝的所有內容都是homebrew 。 任何使用/usr/bin
或/Library/anywhere
都將由Apple提供。
如果您想知道正在運行的實際命令,請使用如下type
:
type python
python is hashed (/usr/local/opt/python/libexec/bin/python)
所以這告訴我,在我的機器上, python
是/usr/local/...
的一個,它必須來自自制軟件,因為它包含/.../LOCAL/...
您的python
當前是/usr/bin/python
。 如果你想使用一個自制軟件 ,你需要在你登錄的個人資料更改PATH,把/usr/local/opt/python/libexec/bin
之前 /usr/bin
。 例如:
export PATH=/usr/local/opt/python/libexec/bin:$PATH
然后啟動一個新的終端,以便您使用新的配置文件運行。
注意區別:
# Run the old Apple-supplied Python
/usr/bin/python -V
Python 2.7.10
# Run the shiny new homebrew Python
/usr/local/opt/python/libexec/bin/python -V
Python 3.7.1
# Run the homebrew pip - that installs into /something/LOCAL/something - sure sign it is not Apple's
/usr/local/opt/python/libexec/bin/pip show pip
Name: pip
Version: 18.1
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: pypa-dev@groups.google.com
License: MIT
Location: /usr/local/lib/python3.7/site-packages
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.