我无法弄清楚如何在运行Anaconda(conda 4.3.18)python 2.7.10的Mac(Sierra 10.12.4)上安装PIL。 Anaconda的默认python是3.5.2,所以我用pip2
安装。
My-MacBook-ProX:dymax thisuser$ sudo pip2 install PIL
Password:
Checking the installation location...
Getting information about 'PIL'...
2.0
Traceback (most recent call last):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/pip2/commands/install.py", line 44, in install
success = packaging.install.install(project)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/install.py", line 515, in install
info = get_infos(project)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/install.py", line 309, in get_infos
installed = list(get_distributions(use_egg_info=True))
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 440, in get_distributions
_generate_cache(use_egg_info, paths)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 103, in _generate_cache
for dist in _yield_distributions(gen_dist, gen_egg, paths):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 88, in _yield_distributions
yield Distribution(dist_path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 146, in __init__
self.metadata = Metadata(path=metadata_path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 219, in __init__
self.read(path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 323, in read
self.read_file(fp)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 330, in read_file
for field in _version2fieldlist(self['Metadata-Version']):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 95, in _version2fieldlist
raise MetadataUnrecognizedVersionError(version)
distutils2.errors.MetadataUnrecognizedVersionError: 2.0
Traceback (most recent call last):
File "/Users/thisuser/anaconda3/bin/pip2", line 11, in <module>
load_entry_point('pip2==0.0.1.dev1', 'console_scripts', 'pip2')()
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/pip2/__init__.py", line 19, in main
args.func(args)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/pip2/cli_wrapper.py", line 24, in install
result = pip2.commands.install.install(args.project_list)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/pip2/commands/install.py", line 44, in install
success = packaging.install.install(project)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/install.py", line 515, in install
info = get_infos(project)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/install.py", line 309, in get_infos
installed = list(get_distributions(use_egg_info=True))
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 440, in get_distributions
_generate_cache(use_egg_info, paths)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 103, in _generate_cache
for dist in _yield_distributions(gen_dist, gen_egg, paths):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 88, in _yield_distributions
yield Distribution(dist_path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 146, in __init__
self.metadata = Metadata(path=metadata_path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 219, in __init__
self.read(path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 323, in read
self.read_file(fp)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 330, in read_file
for field in _version2fieldlist(self['Metadata-Version']):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 95, in _version2fieldlist
raise MetadataUnrecognizedVersionError(version)
distutils2.errors.MetadataUnrecognizedVersionError: 2.0
我为sudo pip2 install pillow
收到相同的错误。我也试过了conda
:
My-MacBook-ProX:dymax thisuser$ conda install pillow
Fetching package metadata ...........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /Users/thisuser/anaconda3:
#
pillow 4.1.1 py35_0
在Python3中,我可以导入PIL。 Python2.7我仍然得到No module named PIL
。感谢您的帮助。我的pip
/ pip2
配置不正确吗?
答案 0 :(得分:0)
尝试提供版本
pip install pillow==6.1.0(latest)
如果不起作用,请尝试
pip list
如果未列出python的搜索位置
which python
在生成的“ python”的位置(通常在lib / python3.5 / site-packages下)中搜索site-packages文件夹,并检查是否存在PIL(软件包未安装正确的位置)