簡體   English   中英

使用 pip 在 Python 3.8.0 中安裝 numpy 時如何修復“錯誤:命令錯誤退出狀態 1”

[英]How to fix “ERROR: Command errored out with exit status 1” when using pip to install numpy in Python 3.8.0

After upgrading Python to 3.8.0, I have trouble installing packages related to numpy using pip, including numpy, matplotlib and sklearn. 錯誤信息如下:

我應該怎么做才能解決這個問題?

C:\WINDOWS\System32>pip install numpy

...

Installing collected packages: numpy
    Running setup.py install for numpy ... error
    ERROR: Command errored out with exit status 1:                                                                           command: 'c:\users\tonakai\appdata\local\programs\python\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Tonakai\\AppData\\Local\\Temp\\pip-install-ub45_c1a\\numpy\\setup.py'"'"'; __file__='"'"'C:\\Users\\Tonakai\\AppData\\Local\\Temp\\pip-install-ub45_c1a\\numpy\\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\Tonakai\AppData\Local\Temp\pip-record-3pg_3uvq\install-record.txt' --single-version-externally-managed --compile
         cwd: C:\Users\Tonakai\AppData\Local\Temp\pip-install-ub45_c1a\numpy\
    Complete output (299 lines):
    Running from numpy source directory.

    Note: if you need reliable uninstall behavior, then install
    with pip instead of using `setup.py install`:

      - `pip install .`       (from a git repo or downloaded source
                               release)
      - `pip install numpy`   (last NumPy release on PyPi)

  blas_mkl_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries mkl_rt not found in ['c:\\users\\tonakai\\appdata\\local\\programs\\python\\python38\\lib', 'C:\\', 'c:\\users\\tonakai\\appdata\\local\\programs\\python\\python38\\libs']
    NOT AVAILABLE
...

c:\users\tonakai\appdata\local\programs\python\python38\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'define_macros'
      warnings.warn(msg)
    non-existing path in 'numpy\\random': 'src\\splitmix64\\splitmix.h'
    running install
    running build
    running config_cc
    unifing config_cc, config, build_clib, build_ext, build commands --compiler options
    running config_fc
    unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
    running build_src
    build_src
    building py_modules sources
    building library "npymath" sources
    No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\tonakai\appdata\local\programs\python\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Tonakai\\AppData\\Local\\Temp\\pip-install-ub45_c1a\\numpy\\setup.py'"'"'; __file__='"'"'C:\\Users\\Tonakai\\AppData\\Local\\Temp\\pip-install-ub45_c1a\\numpy\\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\Tonakai\AppData\Local\Temp\pip-record-3pg_3uvq\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

您需要升級setuptools和 pip。 你可以通過運行來做到這一點:

pip install -U pip setuptools

然后你可以運行你的pip install numpy

升級到 Python 3.8 后我遇到了同樣的問題,也許這些軟件包與 3.8 不兼容?

當我安裝 cx_Oracle 時,我的情況與 python 3.8 相同

c:\Users\paulo.mota\Desktop\RoboBlob>pip install cx_Oracle Collecting cx_Oracle Using cached https://files.pythonhosted.org/packages/d0/00/2d4b1e27da6dda2408dcfe4e192b26c2e190be573c6aadb0c97739f15774/cx_Oracle-7.2.3.tar.gz Building wheels for收集的軟件包:cx-Oracle Building wheel for cx-Oracle (setup.py)... 錯誤錯誤:命令出錯,退出狀態為 1:命令:'c:\program files (x86)\python38-32\python.exe ' -u -c '導入系統,設置工具,標記化; sys.argv[0] = '"'"'C:\Users\paulo.mota\AppData\Local\Temp\pip-install-38ong8sd\cx-Oracle\setup.py'"'"'; file ='"'"'C:\Users\paulo.mota\AppData\Local\Temp\pip-install-38ong8sd\cx-Oracle\setup.py'"'"';f=getattr(tokenize, '"' "'open'"'"', open)( file );code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"' "');f.close();exec(compile(code, file , '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\paulo.mota\AppData\Local\Temp \pip-wheel-avcyfia8' --python-tag cp38 cwd: C:\Users\paulo.mota\AppData\Local\Temp\pip-install-38ong8sd\cx-Oracle\ Complete output 行:運行 b51構建運行 build_ext 構建 'cx_Oracle' 擴展 Traceback(最近一次調用最后):文件“”,第 1 行,在文件“C:\Users\paulo.mota\AppData\Local\Temp\pip-install-38ong8sd\cx-Oracle \setup.py",第 110 行,在 setup( 文件 "c:\program files (x86)\python38-32\lib\site-packages\setuptools__init__.py",第 145 行,在 setup 返回 distutils.core.setup( **attrs) 文件“c:\program files (x86)\python38-32\lib\distutils\core.py”,第 148 行,在 setup dist.run_commands() Fil e "c:\program files (x86)\python38-32\lib\distutils\dist.py",第 966 行,在 run_commands self.run_command(cmd) File "c:\program files (x86)\python38-32\ lib\distutils\dist.py”,第 985 行,在 run_command cmd_obj.run() 文件中“c:\program files (x86)\python38-32\lib\site-packages\wheel\bdist_wheel.py”,第 192 行,在運行 self.run_command('build') 文件“c:\program files (x86)\python38-32\lib\distutils\cmd.py”,第 313 行,在 run_command self.distribution.run_command(command) 文件“c :\program files (x86)\python38-32\lib\distutils\dist.py",第 985 行,在 run_command cmd_obj.run() 文件 "c:\program files (x86)\python38-32\lib\distutils\ command\build.py”,第 135 行,在運行中 self.run_command(cmd_name) 文件“c:\program files (x86)\python38-32\lib\distutils\cmd.py”,第 313 行,在 run_command self.distribution .run_command(command) 文件“c:\program files (x86)\python38-32\lib\distutils\dist.py”,第 985 行,run_command cmd_obj.run() 文件“c:\program files (x86)\ python38-32\lib\site-packages\setuptools\command\b uild_ext.py”,第 84 行,運行中() 文件“c:\program files (x86)\python38-32\lib\distutils\command\build_ext.py”,第 449 行,在 build_extensions self._build_extensions_serial() 文件“c:\program files (x86)\python38 -32\lib\distutils\command\build_ext.py”,第 474 行,在 _build_extensions_serial self.build_extension(ext) 文件“c:\program files (x86)\python38-32\lib\site-packages\setuptools\command\ build_ext.py”,第 205 行,在 build_extension 中= self.compiler.compile(sources, File "c:\program files (x86)\python38-32\lib\distutils_msvccompiler.py", line 360, in compile self.initialize() File "c:\program files (x86 )\python38-32\lib\distutils_msvccompiler.py",第 253 行,初始化 vc_env = _get_vc_env(plat_spec)文件“c:\program files (x86)\python38-32\lib\site-packages\setuptools\msvc.py”,第 170 行,在 msvc14_get_vc_env 返回 EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env() 文件“c: \program 文件 (x86)\python38-32\lib\site-packages\setuptools\msvc.py",第 1619 行,如果 self.vs_ver >= 14 和 isfile(self.VCRuntimeRedist),則在 return_env 中:文件“c:\program files (x86)\python38-32\lib\genericpath.py",第 30 行,在 isfile st = os.stat(path) TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType


錯誤:為 cx-Oracle 構建輪子失敗 為 cx-Oracle 運行 setup.py clean 無法構建 cx-Oracle 安裝收集的包:cx-Oracle 為 cx-Oracle 運行 setup.py install ... 錯誤錯誤:命令出錯退出狀態1:命令:'c:\program files (x86)\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\paulo.mota\AppData\Local\Temp\pip-install-38ong8sd\cx-Oracle\setup.py'"'"'; file ='"'"'C:\Users\paulo.mota\AppData\Local\Temp\pip-install-38ong8sd\cx-Oracle\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\paulo.mota\AppData\Local\ Temp\pip-record-is61e710\install-record.txt' --single-version-externally-managed --compile cwd: C:\Users\paulo.mota\AppData\Local\Temp\pip-install-38ong8sd\cx -Oracle\ Complete output(53 行):運行 install running build running build_ext building 'cx_Oracle' extension Traceback(最近一次調用最后):文件“”,第 1 行,在文件“C:\Users\paulo.mota\AppData\ Local\Temp\pip-install-38ong8sd\cx-Oracle\setup.py",第 110 行,在 setup( 文件 "c:\program files (x86)\python38-32\lib\site-packages\setuptools__init__.py" ,第 145 行,在設置中返回 distutils.core.setup(**attrs) File "c:\program files (x86)\python38-32\lib\distutils\core.p y",第 148 行,在 setup dist.run_commands() 文件中 "c:\program files (x86)\python38-32\lib\distutils\dist.py",第 966 行,在 run_commands self.run_command(cmd) 文件中" c:\program files (x86)\python38-32\lib\distutils\dist.py",第 985 行,run_command cmd_obj.run() 文件 "c:\program files (x86)\python38-32\lib\site -packages\setuptools\command\install.py”,第 61 行,在運行中返回 orig.install.run(self) 文件“c:\program files (x86)\python38-32\lib\distutils\command\install.py ",第 545 行,在運行 self.run_command('build') 文件 "c:\program files (x86)\python38-32\lib\distutils\cmd.py",第 313 行,在 run_command self.distribution.run_command(命令)文件“c:\program files (x86)\python38-32\lib\distutils\dist.py”,第 985 行,在 run_command cmd_obj.run() 文件“c:\program files (x86)\python38-32 \lib\distutils\command\build.py”,第 135 行,在運行 self.run_command(cmd_name) 文件“c:\program files (x86)\python38-32\lib\distutils\cmd.py”,第 313 行,在 run_command self.distribution.run_command(command) 文件中" c:\program files (x86)\python38-32\lib\distutils\dist.py",第 985 行,run_command cmd_obj.run() 文件 "c:\program files (x86)\python38-32\lib\site -packages\setuptools\command\build_ext.py",第 84 行,運行中 _build_ext.run(self) 文件 "c:\program files (x86)\python38-32\lib\distutils\command\build_ext.py",行340,在運行 self.build_extensions() 文件“c:\program files (x86)\python38-32\lib\distutils\command\build_ext.py”,第 449 行,在 build_extensions self._build_extensions_serial() 文件“c:\程序文件 (x86)\python38-32\lib\distutils\command\build_ext.py",第 474 行,在 _build_extensions_serial self.build_extension(ext) 文件 "c:\program files (x86)\python38-32\lib\site -packages\setuptools\command\build_ext.py",第 205 行,在 build_extension _build_ext.build_extension(self, ext) 文件 "c:\program files (x86)\python38-32\lib\distutils\command\build_ext.py" ,第 528 行,在 build_extension objects = self.compiler.compile(sources, File "c:\program files (x86)\python38-32\lib\distutils_msvccomp iler.py”,第 360 行,編譯 self.initialize() 文件“c:\program files (x86)\python38-32\lib\distutils_msvccompiler.py”,第 253 行,初始化 vc_env = _get_vc_env(plat_spec) 文件“ c:\program files (x86)\python38-32\lib\site-packages\setuptools\msvc.py",第 170 行,在 msvc14_get_vc_env 返回 EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env() 文件“c:\program文件 (x86)\python38-32\lib\site-packages\setuptools\msvc.py",第 1619 行,如果 self.vs_ver >= 14 和 isfile(self.VCRuntimeRedist),則在 return_env 中:文件“c:\program files ( x86)\python38-32\lib\genericpath.py", line 30, in isfile st = os.stat(path) TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType ---- ------------------------------------ 錯誤:命令出錯,退出狀態為 1:'c:\程序文件 (x86)\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\paulo.mota\AppData\Local\Temp\pip-install-38ong8sd\cx-Oracle\setup.py'"'"'; file ='"'"'C:\Users\paulo.mota\AppData\Local\Temp\pip-install-38ong8sd\cx-Oracle\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\paulo.mota\AppData\Local\ Temp\pip-record-is61e710\install-record.txt' --single-version-externally-managed --compile 檢查日志以獲取完整命令 output。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM