首先,安装每个包的命令后面都加上了镜像-i https://pypi.douban.com/simple
,是因为之前没加镜像都装不上,加了之后报错明显减少很多,可以参考这篇文章python pip install指定国内源镜像
起初,在命令提示符(cmd)中安装jupyter包,使用的是pip install --user jupyter -i https://pypi.douban.com/simple
”命令,结果安装中途报错,如下图。(其中我需要加–user,主要是因为脑热把python装在C盘了,所以需要系统权限)
注意到第二个图中,最后几行:
distutils.errors.DistutilsError: Command '['c:\\users\\asus\\appdata\\local\\programs\\python\\python39\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\asus\\AppData\\Local\\Temp\\tmpi2fi2veo', '--quiet', 'Cython']' returned non-zero exit status 2.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
其中讲到了“-m”等,并且受到博客python xxx.py和python -m xxx.py有什么区别!的启发(路径和启动),加上了python -m,如下:
python -m pip install --user jupyter -i https://pypi.douban.com/simple
Using legacy 'setup.py install' for pandocfilters, since package 'wheel' is not installed.
Using legacy 'setup.py install' for MarkupSafe, since package 'wheel' is not installed.
Using legacy 'setup.py install' for pywinpty, since package 'wheel' is not installed.
Using legacy 'setup.py install' for pyrsistent, since package 'wheel' is not installed.
Installing collected packages: ipython-genutils, traitlets, pywin32, jupyter-core, six, pyrsistent, attrs, jsonschema, nbformat, tornado, pyzmq, prometheus-client, Send2Trash, MarkupSafe, jinja2, webencodings, pyparsing, packaging, bleach, mistune, pygments, jupyterlab-pygments, testpath, nest-asyncio, python-dateutil, jupyter-client, async-generator, nbclient, entrypoints, pandocfilters, defusedxml, nbconvert, pickleshare, decorator, colorama, parso, jedi, wcwidth, prompt-toolkit, backcall, ipython, ipykernel, pycparser, cffi, argon2-cffi, pywinpty, terminado, notebook, widgetsnbextension, ipywidgets, jupyter-console, qtpy, qtconsole, jupyter
Running setup.py install for pyrsistent ... done
Running setup.py install for MarkupSafe ... done
Running setup.py install for pandocfilters ... done
Running setup.py install for pywinpty ... done
Successfully installed MarkupSafe-1.1.1 Send2Trash-1.5.0 argon2-cffi-20.1.0 async-generator-1.10 attrs-20.3.0 backcall-0.2.0 bleach-3.2.1 cffi-1.14.3 colorama-0.4.4 decorator-4.4.2 defusedxml-0.6.0 entrypoints-0.3 ipykernel-5.3.4 ipython-7.19.0 ipython-genutils-0.2.0 ipywidgets-7.5.1 jedi-0.17.2 jinja2-2.11.2 jsonschema-3.2.0 jupyter-1.0.0 jupyter-client-6.1.7 jupyter-console-6.2.0 jupyter-core-4.7.0 jupyterlab-pygments-0.1.2 mistune-0.8.4 nbclient-0.5.1 nbconvert-6.0.7 nbformat-5.0.8 nest-asyncio-1.4.3 notebook-6.1.5 packaging-20.4 pandocfilters-1.4.3 parso-0.7.1 pickleshare-0.7.5 prometheus-client-0.9.0 prompt-toolkit-3.0.8 pycparser-2.20 pygments-2.7.2 pyparsing-2.4.7 pyrsistent-0.17.3 python-dateutil-2.8.1 pywin32-300 pywinpty-0.5.7 pyzmq-20.0.0 qtconsole-4.7.7 qtpy-1.9.0 six-1.15.0 terminado-0.9.1 testpath-0.4.4 tornado-6.1 traitlets-5.0.5 wcwidth-0.2.5 webencodings-0.5.1 widgetsnbextension-3.5.1
安装成功了!
其中,提示由于少了wheel包,所以安装部分包使用的是py旧版本安装,所以后面再装上wheel包即可,防止在出现这种警告。
同上,使用命令python -m pip install --user lmdb -i https://pypi.douban.com/simple
ERROR: Command errored out with exit status 1:
command: 'C:\Users\asus\AppData\Local\Programs\Python\Python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\asus\\AppData\\Local\\Temp\\pip-install-evdmq2_r\\lmdb\\setup.py'"'"'; __file__='"'"'C:\\Users\\asus\\AppData\\Local\\Temp\\pip-install-evdmq2_r\\lmdb\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\asus\AppData\Local\Temp\pip-pip-egg-info-75te6d20'
cwd: C:\Users\asus\AppData\Local\Temp\pip-install-evdmq2_r\lmdb\
Complete output (13 lines):
Traceback (most recent call last):
File "C:\Users\asus\AppData\Local\Temp\pip-install-evdmq2_r\lmdb\setup.py", line 92, in
import patch_ng as patch
ModuleNotFoundError: No module named 'patch_ng'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\asus\AppData\Local\Temp\pip-install-evdmq2_r\lmdb\setup.py", line 94, in
raise Exception('Building py-lmdb from source on Windows requires the "patch-ng" python module.')
Exception: Building py-lmdb from source on Windows requires the "patch-ng" python module.
py-lmdb: Using bundled liblmdb with py-lmdb patches; override with LMDB_FORCE_SYSTEM=1 or LMDB_PURE=1.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
错误提示少了“patch_ng”文件,查了痕迹也没找到解决方案,在网上也没找到过“patch_ng”源文件,但后来突然想,直接也用上面命令安装这个文件行不行(虽然它不是包),结果成功了!
不过换了一个错误:
building 'cpython' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\asus\AppData\Local\Programs\Python\Python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\asus\\AppData\\Local\\Temp\\pip-install-5_hrlujr\\lmdb\\setup.py'"'"'; __file__='"'"'C:\\Users\\asus\\AppData\\Local\\Temp\\pip-install-5_hrlujr\\lmdb\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\asus\AppData\Local\Temp\pip-record-5_daz9p1\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\asus\AppData\Roaming\Python\Python39\Include\lmdb' Check the logs for full command output.
主要是缺少Microsoft Visual C++ 14.0
,可以从这里提取包Microsoft Visual C++ 14.0(安装包)
然后出现了以下错误:
LINK : fatal error LNK1158: cannot run 'rc.exe'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit code 1158
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\asus\AppData\Local\Programs\Python\Python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\asus\\AppData\\Local\\Temp\\pip-install-mwks3ldi\\lmdb\\setup.py'"'"'; __file__='"'"'C:\\Users\\asus\\AppData\\Local\\Temp\\pip-install-mwks3ldi\\lmdb\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\asus\AppData\Local\Temp\pip-record-b72ouex0\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\asus\AppData\Roaming\Python\Python39\Include\lmdb' Check the logs for full command output.
错误是少“LINK : fatal error LNK1158: cannot run ‘rc.exe’”,所以参照一下博客:出现LINK : fatal error LNK1158: cannot run ‘rc.exe’ 错误的解决办法
成功解决问题!
出现错误:
ERROR: Command errored out with exit status 1:
command: 'C:\Users\asus\AppData\Local\Programs\Python\Python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\asus\\AppData\\Local\\Temp\\pip-install-s73j832x\\mahotas\\setup.py'"'"'; __file__='"'"'C:\\Users\\asus\\AppData\\Local\\Temp\\pip-install-s73j832x\\mahotas\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\asus\AppData\Local\Temp\pip-pip-egg-info-x2wxnzoo'
cwd: C:\Users\asus\AppData\Local\Temp\pip-install-s73j832x\mahotas\
Complete output (9 lines):
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\asus\AppData\Local\Temp\pip-install-s73j832x\mahotas\setup.py", line 35, in
import numpy
File "C:\Users\asus\AppData\Roaming\Python\Python39\site-packages\numpy\__init__.py", line 305, in
_win_os_check()
File "C:\Users\asus\AppData\Roaming\Python\Python39\site-packages\numpy\__init__.py", line 302, in _win_os_check
raise RuntimeError(msg.format(__file__)) from None
RuntimeError: The current Numpy installation ('C:\\Users\\asus\\AppData\\Roaming\\Python\\Python39\\site-packages\\numpy\\__init__.py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86
numpy1.19.3;platform_system"Windows"
numpy1.19.4;platform_system"linux"
windows只能安装1.19.3,直接使用pip3 install命令安装的是最新的1.19.4版本,因此在安装时需要指定版本:
先卸载原版本:
pip uninstall numpy
然后安装1.19.3版本:
python -m pip install --user numpy==1.19.3 -i https://pypi.douban.com/simple
这样,继续安装mahotas即可成功