我试图在mac上下载带有scrapy的图像,并返回以下错误消息:
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?
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分期付款
通过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: 有什么办法解决这个问题吗?
发布于 2018-11-30 10:25:54
您想使用哪种版本的Python?您似乎声称您是通过、自制安装的,但是您使用的是由苹果在/usr/bin/python中提供的Python2.7,这就是pip在/Library/Python/2.7中安装的原因。
如果要使用、自制、Python和pip,则需要运行/usr/local/opt/python/libexec/bin/python。如果运行以下命令,您可以看到所有这些信息:
brew info python通常,在/anywhere/LOCAL/anywhere中或在其中安装的任何东西都将是自制。任何使用/usr/bin或/Library/anywhere的产品都将由苹果公司提供。
如果您想知道正在运行的实际命令,请使用type,如下所示:
type python
python is hashed (/usr/local/opt/python/libexec/bin/python)这就告诉我,在我的机器上,python是/usr/local/...中的一个,它必须来自homebrew,因为它包含/.../LOCAL/...。
您的python当前是/usr/bin/python。如果您想使用自制 one,则需要更改登录配置文件中的路径,并将/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-packageshttps://stackoverflow.com/questions/53554049
复制相似问题