【问题标题】:Numpy Does Not InstallNumpy 不安装
【发布时间】:2020-03-28 01:29:36
【问题描述】:

我基本上是在尝试安装 Pandas,但要做到这一点,我应该安装 Numpy。

我在终端输入这个:

pip 安装 numpy

我收到一个错误,基本上说我需要 Microsoft Visual Studio C++ 14.0。从它提供的链接下载它后,我完全不知道如何使用它。我尝试使用 YouTube 教程来了解如何使用 Visual Studio,但是当他们创建项目时,我没有任何选择。我唯一的选择是创建一个空白解决方案。

如果需要其他错误消息,请提醒我,我才开始使用 Python 几个月,所以我不是很有经验。

错误信息:

(venv) C:\Users\pc\PycharmProjects\Tutorials>pip install numpy
Collecting numpy
  Using cached https://files.pythonhosted.org/packages/84/1e/ff467ac56bfeaea51d4a2e72d315c1fe440b20192fea7e460f0f248acac8/numpy-1.18.2.zip
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    Complete output from command C:\Users\pc\PycharmProjects\Tutorials\venv\Scripts\python.exe C:\Users\pc\PycharmProjects\Tutorials\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\pep517\_in_process.py prepare_meta
data_for_build_wheel C:\Users\pc\AppData\Local\Temp\tmp7lo0j8qw:
    Processing numpy/random\_bounded_integers.pxd.in
    Processing numpy/random\mtrand.pyx
    Processing numpy/random\_bit_generator.pyx
    Processing numpy/random\_bounded_integers.pyx.in
    Processing numpy/random\_common.pyx
    Processing numpy/random\_generator.pyx
    Processing numpy/random\_mt19937.pyx
    Processing numpy/random\_pcg64.pyx
    Processing numpy/random\_philox.pyx
    Processing numpy/random\_sfc64.pyx
    Cythonizing sources
    blas_opt_info:
    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\\pc\\PycharmProjects\\Tutorials\\venv\\lib', 'C:\\']
      NOT AVAILABLE

    blis_info:
      libraries blis not found in ['C:\\Users\\pc\\PycharmProjects\\Tutorials\\venv\\lib', 'C:\\']
      NOT AVAILABLE

    openblas_info:
      libraries openblas not found in ['C:\\Users\\pc\\PycharmProjects\\Tutorials\\venv\\lib', 'C:\\']
    get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
    customize GnuFCompiler
    Could not locate executable g77
    Could not locate executable f77
    customize IntelVisualFCompiler
    Could not locate executable ifort
    Could not locate executable ifl
    customize AbsoftFCompiler
    Could not locate executable f90
    customize CompaqVisualFCompiler
    Could not locate executable DF
    customize IntelItaniumVisualFCompiler
    Could not locate executable efl
    customize Gnu95FCompiler
    Could not locate executable gfortran
    Could not locate executable f95
    customize G95FCompiler
    Could not locate executable g95
    customize IntelEM64VisualFCompiler
    customize IntelEM64TFCompiler
    Could not locate executable efort
    Could not locate executable efc
    customize PGroupFlangCompiler
    Could not locate executable flang
    don't know how to compile Fortran code on platform 'nt'
      NOT AVAILABLE

    atlas_3_10_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries tatlas not found in ['C:\\Users\\pc\\PycharmProjects\\Tutorials\\venv\\lib', 'C:\\']
      NOT AVAILABLE

    atlas_3_10_blas_info:
      libraries satlas not found in ['C:\\Users\\pc\\PycharmProjects\\Tutorials\\venv\\lib', 'C:\\']
      NOT AVAILABLE

    atlas_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries ptf77blas,ptcblas,atlas not found in ['C:\\Users\\pc\\PycharmProjects\\Tutorials\\venv\\lib', 'C:\\']
      NOT AVAILABLE

    atlas_blas_info:
      libraries f77blas,cblas,atlas not found in ['C:\\Users\\pc\\PycharmProjects\\Tutorials\\venv\\lib', 'C:\\']
      NOT AVAILABLE

    accelerate_info:
      NOT AVAILABLE

    blas_info:
      libraries blas not found in ['C:\\Users\\pc\\PycharmProjects\\Tutorials\\venv\\lib', 'C:\\']
      NOT AVAILABLE

    blas_src_info:
      NOT AVAILABLE

      NOT AVAILABLE

    non-existing path in 'numpy\\distutils': 'site.cfg'
    lapack_opt_info:
    lapack_mkl_info:
      libraries mkl_rt not found in ['C:\\Users\\pc\\PycharmProjects\\Tutorials\\venv\\lib', 'C:\\']
      NOT AVAILABLE

    openblas_lapack_info:
      libraries openblas not found in ['C:\\Users\\pc\\PycharmProjects\\Tutorials\\venv\\lib', 'C:\\']
      NOT AVAILABLE

    openblas_clapack_info:
      libraries openblas,lapack not found in ['C:\\Users\\pc\\PycharmProjects\\Tutorials\\venv\\lib', 'C:\\']
      NOT AVAILABLE

    flame_info:
      libraries flame not found in ['C:\\Users\\pc\\PycharmProjects\\Tutorials\\venv\\lib', 'C:\\']
      NOT AVAILABLE

    atlas_3_10_threads_info:
    Setting PTATLAS=ATLAS
      libraries lapack_atlas not found in C:\Users\pc\PycharmProjects\Tutorials\venv\lib
      libraries tatlas,tatlas not found in C:\Users\pc\PycharmProjects\Tutorials\venv\lib
      libraries lapack_atlas not found in C:\
      libraries tatlas,tatlas not found in C:\
    <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
      NOT AVAILABLE

    atlas_3_10_info:
      libraries lapack_atlas not found in C:\Users\pc\PycharmProjects\Tutorials\venv\lib
      libraries satlas,satlas not found in C:\Users\pc\PycharmProjects\Tutorials\venv\lib
      libraries lapack_atlas not found in C:\
      libraries satlas,satlas not found in C:\
    <class 'numpy.distutils.system_info.atlas_3_10_info'>
      NOT AVAILABLE

    atlas_threads_info:
    Setting PTATLAS=ATLAS
      libraries lapack_atlas not found in C:\Users\pc\PycharmProjects\Tutorials\venv\lib
      libraries ptf77blas,ptcblas,atlas not found in C:\Users\pc\PycharmProjects\Tutorials\venv\lib
      libraries lapack_atlas not found in C:\
      libraries ptf77blas,ptcblas,atlas not found in C:\
    <class 'numpy.distutils.system_info.atlas_threads_info'>
      NOT AVAILABLE

    atlas_info:
      libraries lapack_atlas not found in C:\Users\pc\PycharmProjects\Tutorials\venv\lib
      libraries f77blas,cblas,atlas not found in C:\Users\pc\PycharmProjects\Tutorials\venv\lib
      libraries lapack_atlas not found in C:\
      libraries f77blas,cblas,atlas not found in C:\
    <class 'numpy.distutils.system_info.atlas_info'>
      NOT AVAILABLE

    lapack_info:
      libraries lapack not found in ['C:\\Users\\pc\\PycharmProjects\\Tutorials\\venv\\lib', 'C:\\']
      NOT AVAILABLE

    lapack_src_info:
      NOT AVAILABLE

      NOT AVAILABLE

    running dist_info
    running build_src
    build_src
    building py_modules sources
    creating build
    creating build\src.win-amd64-3.8
    creating build\src.win-amd64-3.8\numpy
    creating build\src.win-amd64-3.8\numpy\distutils
    building library "npymath" sources
    Running from numpy source directory.
    setup.py:461: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
      run_build = parse_setuppy_commands()
    C:\Users\pc\AppData\Local\Temp\pip-install-az7mvo02\numpy\numpy\distutils\system_info.py:1896: UserWarning:
        Optimized (vendor) Blas libraries are not found.
        Falls back to netlib Blas library which has worse performance.
        A better performance should be easily gained by switching
        Blas library.
      if self._calc_info(blas):
    C:\Users\pc\AppData\Local\Temp\pip-install-az7mvo02\numpy\numpy\distutils\system_info.py:1896: UserWarning:
        Blas (http://www.netlib.org/blas/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [blas]) or by setting
        the BLAS environment variable.
      if self._calc_info(blas):
    C:\Users\pc\AppData\Local\Temp\pip-install-az7mvo02\numpy\numpy\distutils\system_info.py:1896: UserWarning:
        Blas (http://www.netlib.org/blas/) sources not found.
        Directories to search for the sources can be specified in the
        numpy/distutils/site.cfg file (section [blas_src]) or by setting
        the BLAS_SRC environment variable.
      if self._calc_info(blas):
    C:\Users\pc\AppData\Local\Temp\pip-install-az7mvo02\numpy\numpy\distutils\system_info.py:1730: UserWarning:
        Lapack (http://www.netlib.org/lapack/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [lapack]) or by setting
        the LAPACK environment variable.
      return getattr(self, '_calc_info_{}'.format(name))()
    C:\Users\pc\AppData\Local\Temp\pip-install-az7mvo02\numpy\numpy\distutils\system_info.py:1730: UserWarning:
        Lapack (http://www.netlib.org/lapack/) sources not found.
        Directories to search for the sources can be specified in the
        numpy/distutils/site.cfg file (section [lapack_src]) or by setting
        the LAPACK_SRC environment variable.
      return getattr(self, '_calc_info_{}'.format(name))()
    C:\Users\pc\AppData\Local\Programs\Python\Python38\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'define_macros'
      warnings.warn(msg)
    error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/

    ----------------------------------------
Command "C:\Users\pc\PycharmProjects\Tutorials\venv\Scripts\python.exe C:\Users\pc\PycharmProjects\Tutorials\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\pep517\_in_process.py prepare_metadata_for_build_wheel C:\
Users\pc\AppData\Local\Temp\tmp7lo0j8qw" failed with error code 1 in C:\Users\pc\AppData\Local\Temp\pip-install-az7mvo02\numpy

升级pip时出错:

(venv) C:\Users\pc\PycharmProjects\Tutorials>python -m pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 2.2MB/s
Installing collected packages: pip
  Found existing installation: pip 19.0.3
    Uninstalling pip-19.0.3:
      Successfully uninstalled pip-19.0.3
  Rolling back uninstall of pip
  Moving to c:\users\pc\pycharmprojects\tutorials\venv\lib\site-packages\pip-19.0.3-py3.8.egg
   from C:\Users\pc\PycharmProjects\Tutorials\venv\Lib\site-packages\~ip-19.0.3-py3.8.egg
  Moving to c:\users\pc\pycharmprojects\tutorials\venv\scripts\pip-script.py
   from C:\Users\pc\AppData\Local\Temp\pip-uninstall-hqx4h1fb\pip-script.py
  Moving to c:\users\pc\pycharmprojects\tutorials\venv\scripts\pip.exe
   from C:\Users\pc\AppData\Local\Temp\pip-uninstall-hqx4h1fb\pip.exe
  Moving to c:\users\pc\pycharmprojects\tutorials\venv\scripts\pip3-script.py
   from C:\Users\pc\AppData\Local\Temp\pip-uninstall-hqx4h1fb\pip3-script.py
  Moving to c:\users\pc\pycharmprojects\tutorials\venv\scripts\pip3.8-script.py
   from C:\Users\pc\AppData\Local\Temp\pip-uninstall-hqx4h1fb\pip3.8-script.py
  Moving to c:\users\pc\pycharmprojects\tutorials\venv\scripts\pip3.8.exe
   from C:\Users\pc\AppData\Local\Temp\pip-uninstall-hqx4h1fb\pip3.8.exe
  Moving to c:\users\pc\pycharmprojects\tutorials\venv\scripts\pip3.exe
   from C:\Users\pc\AppData\Local\Temp\pip-uninstall-hqx4h1fb\pip3.exe
Exception:
Traceback (most recent call last):
  File "C:\Users\pc\PycharmProjects\Tutorials\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\cli\base_command.py", line 179, in main
    status = self.run(options, args)
  File "C:\Users\pc\PycharmProjects\Tutorials\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\commands\install.py", line 384, in run
    installed = install_given_reqs(
  File "C:\Users\pc\PycharmProjects\Tutorials\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\req\__init__.py", line 53, in install_given_reqs
    requirement.install(
  File "C:\Users\pc\PycharmProjects\Tutorials\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\req\req_install.py", line 910, in install
    self.move_wheel_files(
  File "C:\Users\pc\PycharmProjects\Tutorials\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\req\req_install.py", line 437, in move_wheel_files
    move_wheel_files(
  File "C:\Users\pc\PycharmProjects\Tutorials\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\wheel.py", line 544, in move_wheel_files
    generated.extend(maker.make(spec))
  File "C:\Users\pc\PycharmProjects\Tutorials\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\distlib\scripts.py", line 405, in make
    self._make_script(entry, filenames, options=options)
  File "C:\Users\pc\PycharmProjects\Tutorials\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\distlib\scripts.py", line 309, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "C:\Users\pc\PycharmProjects\Tutorials\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\distlib\scripts.py", line 245, in _write_script
    launcher = self._get_launcher('t')
  File "C:\Users\pc\PycharmProjects\Tutorials\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\distlib\scripts.py", line 384, in _get_launcher
    result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'

【问题讨论】:

  • 你在哪个平台上?听起来好像您的平台没有二进制版本的 NumPy。
  • 如果你包含你得到的错误会有所帮助。如果是冗长的错误消息,请先包含最后 20 行左右。
  • 我使用的是 Windows 10。
  • Windows 10 应该有二进制 NumPy 版本,因此您确实应该在问题中包含错误消息以查看实际问题。
  • 我应该在评论中发布它吗?这是我第一次使用这个网站。

标签: python numpy


【解决方案1】:

有几个选择:

1) 从Unofficial Windows Binaries for Python Extension Packages下载二进制文件

对于不提供自己的 Windows 安装程序的项目(以及 甚至有些确实如此),加利福尼亚大学的克里斯托夫·戈尔克(Christoph Gohlke) 提供 Windows 安装程序的集合。许多 Python 用户在 Windows 报告了这些预建的积极体验 版本。 Source

https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

搜索并下载:

numpy-1.18.2+mkl-cp38-cp38-win_amd64.whl

打开终端,激活您的环境,然后安装(更改下载文件的路径):

pip install C:\Users\pc\downloads\numpy‑1.18.2+mkl‑cp38‑cp38‑win_amd64.whl

2) 由于您使用的是 Windows(就像我一样),我强烈建议您利用 Python 的 Anaconda 分发版。从长远来看,将为您节省大量时间。基本上,它会安装二进制包,而不是要求您使用 pip 编译资源。

由于你使用的是Pycharm,安装Anaconda后,回到Pycharm,使用Conda创建一个新环境,然后pip install numpy。

3) 尝试编译(祝你好运)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-24
    • 2014-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多