首先
安裝 python
然後
在安裝 pip
最後
在 cmd 下執行以下命令報錯
pip install qrcode
pip install pillow
cmd 執行pip install qrcode 命令報錯困擾我了 幾個月,
報錯如下:
C:\Users\cby>pip install qrcode
Downloading/unpacking qrcode
Downloading qrcode-6.1-py2.py3-none-any.whl
Cleaning up...
Exception:
Traceback (most recent call last):
File "C:\install\python3.4\lib\site-packages\pip\_vendor\pkg_resources.py", line 2421, in _dep_map
return self.__dep_map
File "C:\install\python3.4\lib\site-packages\pip\_vendor\pkg_resources.py", line 2283, in __getattr__
raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\install\python3.4\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\install\python3.4\lib\site-packages\pip\commands\install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "C:\install\python3.4\lib\site-packages\pip\req.py", line 1265, in prepare_files
req_to_install.extras):
File "C:\install\python3.4\lib\site-packages\pip\_vendor\pkg_resources.py", line 2232, in requires
dm = self._dep_map
File "C:\install\python3.4\lib\site-packages\pip\_vendor\pkg_resources.py", line 2423, in _dep_map
self.__dep_map = self._compute_dependencies()
File "C:\install\python3.4\lib\site-packages\pip\_vendor\pkg_resources.py", line 2456, in _compute_dependencies
common = frozenset(reqs_for_extra(None))
File "C:\install\python3.4\lib\site-packages\pip\_vendor\pkg_resources.py", line 2453, in reqs_for_extra
if req.marker_fn(override={'extra':extra}):
File "C:\install\python3.4\lib\site-packages\pip\_vendor\_markerlib\markers.py", line 113, in marker_fn
return eval(compiled_marker, environment)
File "<environment marker>", line 1, in <module>
NameError: name 'platform_system' is not defined
Storing debug log for failure in C:\Users\cby\pip\pip.log
解決辦法
更新 pip
python -m pip install --upgrade pip
Downloading/unpacking pip from https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl#sha256=340a0ba40fdeb16413914c0fcd8e0b4ebb0bf39a900ec80e11c05d836c05103f
Installing collected packages: pip
Found existing installation: pip 1.5.4
Uninstalling pip:
Successfully uninstalled pip
Successfully installed pip
Cleaning up...
再進行安裝 qrcode 安裝成功了。
執行安裝命令 pip install pillow 時候報錯 ,修改命令 pip install Pillow 執行 成功。
爲什麼安裝的不是PIL呢?PIL模塊只支持python2.7及以下版本,python3之後無法使用,官方推薦python3.x使用Pillow代替PIL模塊,實際上Pillow的與PIL完全兼容,部分功能還得到完善。
如果不想使用pip安裝,或者想單獨下載離線安裝,請登陸python官網PyPI欄目,搜索pillow,並選擇最新版本。
參考 https://pypi.org/project/Pillow/3.2.0/#files