Pip install numpy ошибка

Note

Since this information may be updated regularly, please ensure you are
viewing the most up-to-date version.

ImportError#

In certain cases a failed installation or setup issue can cause you to
see the following error message:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy c-extensions failed. This error can happen for
different reasons, often due to issues with your setup.

The error also has additional information to help you troubleshoot:

  • Your Python version

  • Your NumPy version

Please check both of these carefully to see if they are what you expect.
You may need to check your PATH or PYTHONPATH environment variables
(see Check Environment Variables below).

The following sections list commonly reported issues depending on your setup.
If you have an issue/solution that you think should appear please open a
NumPy issue so that it will be added.

There are a few commonly reported issues depending on your system/setup.
If none of the following tips help you, please be sure to note the following:

  • how you installed Python

  • how you installed NumPy

  • your operating system

  • whether or not you have multiple versions of Python installed

  • if you built from source, your compiler versions and ideally a build log

when investigating further and asking for support.

Using Python from conda (Anaconda)#

Please make sure that you have activated your conda environment.
See also the conda user-guide.
If you use an external editor/development environment it will have to be set
up correctly. See below for solutions for some common setups.

Using PyCharm with Anaconda/conda Python#

There are fairly common issues when using PyCharm together with Anaconda,
please see the PyCharm support

Using VSCode with Anaconda/conda Python (or environments)#

A commonly reported issue is related to the environment activation within
VSCode. Please see the VSCode support
for information on how to correctly set up VSCode with virtual environments
or conda.

Using Eclipse/PyDev with Anaconda/conda Python (or environments)#

Please see the
Anaconda Documentation
on how to properly configure Eclipse/PyDev to use Anaconda Python with specific
conda environments.

Raspberry Pi#

There are sometimes issues reported on Raspberry Pi setups when installing
using pip3 install (or pip install). These will typically mention:

libf77blas.so.3: cannot open shared object file: No such file or directory

The solution will be to either:

sudo apt-get install libatlas-base-dev

to install the missing libraries expected by the self-compiled NumPy
(ATLAS is a possible provider of linear algebra).

Alternatively use the NumPy provided by Raspbian. In which case run:

pip3 uninstall numpy  # remove previously installed version
apt install python3-numpy

Debug build on Windows#

Rather than building your project in DEBUG mode on windows, try
building in RELEASE mode with debug symbols and no optimization.
Full DEBUG mode on windows changes the names of the DLLs python
expects to find, so if you wish to truly work in DEBUG mode you will
need to recompile the entire stack of python modules you work with
including NumPy

All Setups#

Occasionally there may be simple issues with old or bad installations
of NumPy. In this case you may just try to uninstall and reinstall NumPy.
Make sure that NumPy is not found after uninstalling.

Development Setup#

If you are using a development setup, make sure to run git clean -xdf
to delete all files not under version control (be careful not to lose
any modifications you made, e.g. site.cfg).
In many cases files from old builds may lead to incorrect builds.

Check Environment Variables#

In general how to set and check your environment variables depends on
your system. If you can open a correct python shell, you can also run the
following in python:

import os
print("PYTHONPATH:", os.environ.get('PYTHONPATH'))
print("PATH:", os.environ.get('PATH'))

This may mainly help you if you are not running the python and/or NumPy
version you are expecting to run.

C-API incompatibility#

If you see an error like:

RuntimeError: module compiled against API version v1 but this version of numpy is v2

You may have:

  • A bad extension “wheel” (binary install) that should use
    oldest-support-numpy (
    with manual constraints if necessary) to build their binary packages.

  • An environment issue messing with package versions.

  • Incompatible package versions somehow enforced manually.

  • An extension module compiled locally against a very recent version
    followed by a NumPy downgrade.

  • A compiled extension copied to a different computer with an
    older NumPy version.

The best thing to do if you see this error is to contact
the maintainers of the package that is causing problem
so that they can solve the problem properly.

However, while you wait for a solution, a work around
that usually works is to upgrade the NumPy version:

pip install numpy --upgrade

Segfaults or crashes#

NumPy tries to use advanced CPU features (SIMD) to speed up operations. If you
are getting an “illegal instruction” error or a segfault, one cause could be
that the environment claims it can support one or more of these features but
actually cannot. This can happen inside a docker image or a VM (qemu, VMWare,
…)

You can use the output of np.show_runtime() to show which SIMD features are
detected. For instance:

>>> np.show_runtime()
WARNING: `threadpoolctl` not found in system! Install it by `pip install \
threadpoolctl`. Once installed, try `np.show_runtime` again for more detailed
build information
[{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
                      'found': ['SSSE3',
                                'SSE41',
                                'POPCNT',
                                'SSE42',
                                'AVX',
                                'F16C',
                                'FMA3',
                                'AVX2'],
                      'not_found': ['AVX512F',
                                    'AVX512CD',
                                    'AVX512_KNL',
                                    'AVX512_KNM',
                                    'AVX512_SKX',
                                    'AVX512_CLX',
                                    'AVX512_CNL',
                                    'AVX512_ICL']}}]

In this case, it shows AVX2 and FMA3 under the found section, so you can
try disabling them by setting NPY_DISABLE_CPU_FEATURES="AVX2,FMA3" in your
environment before running python (for cmd.exe on windows):

>SET NPY_DISABLE_CPU_FEATURES="AVX2,FMA3"
>python <myprogram.py>

By installing threadpoolctl np.show_runtime() will show additional information:

...
{'architecture': 'Zen',
  'filepath': '/tmp/venv3/lib/python3.9/site-packages/numpy.libs/libopenblas64_p-r0-15028c96.3.21.so',
  'internal_api': 'openblas',
  'num_threads': 24,
  'prefix': 'libopenblas',
  'threading_layer': 'pthreads',
  'user_api': 'blas',
  'version': '0.3.21'}]

If you use the wheel from PyPI, it contains code from the OpenBLAS project to
speed up matrix operations. This code too can try to use SIMD instructions. It
has a different mechanism for choosing which to use, based on a CPU
architecture, You can override this architecture by setting
OPENBLAS_CORETYPE: a minimal value for x86_64 is
OPENBLAS_CORETYPE=Haswell. This too needs to be set before running your
python (this time for posix):

$ OPENBLAS_CORETYPE=Haswell python <myprogram.py>

  • Редакция Кодкампа


читать 1 мин


Одна распространенная ошибка, с которой вы можете столкнуться при использовании Python:

Import error: no module named ' numpy '

Эта ошибка возникает, когда Python не обнаруживает библиотеку NumPy в вашей текущей среде.

В этом руководстве представлены точные шаги, которые вы можете использовать для устранения этой ошибки.

Шаг 1: pip установить numpy

Поскольку NumPy не устанавливается автоматически вместе с Python, вам нужно будет установить его самостоятельно. Самый простой способ сделать это — использовать pip , менеджер пакетов для Python.

Вы можете запустить следующую команду pip для установки NumPy:

pip install numpy

Для python 3 вы можете использовать:

pip3 install numpy

В большинстве случаев это исправит ошибку.

Шаг 2: Установите пип

Если вы все еще получаете сообщение об ошибке, вам может потребоваться установить pip. Используйте эти шаги , чтобы сделать это.

Вы также можете использовать эти шаги для обновления pip до последней версии, чтобы убедиться, что он работает.

Затем вы можете запустить ту же команду pip, что и раньше, чтобы установить NumPy:

pip install numpy

На этом этапе ошибка должна быть устранена.

Шаг 3: проверьте версию NumPy

После успешной установки NumPy вы можете использовать следующую команду для отображения версии NumPy в вашей среде:

pip show numpy

Name: numpy
Version: 1.20.3
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location: /srv/conda/envs/notebook/lib/python3.7/site-packages
Requires: 
Required-by: tensorflow, tensorflow-estimator, tensorboard, statsmodels, seaborn,
scipy, scikit-learn, PyWavelets, patsy, pandas, matplotlib, Keras-Preprocessing,
Keras-Applications, imageio, h5py, bqplot, bokeh, altair
Note: you may need to restart the kernel to use updated packages.

Дополнительные ресурсы

В следующих руководствах объясняется, как исправить другие распространенные проблемы в Python:

Как исправить: нет модуля с именем pandas
Как исправить: нет модуля с именем plotly
Как исправить: имя NameError ‘pd’ не определено
Как исправить: имя NameError ‘np’ не определено

Hi @seberg and @ksunden

Run the code with no cache dir param but no success, on the first moment, looks good but the same error. Also, I already have the Anaconda, this was my first workaround for the issue, once I need python for my test on university
`C:\Users\Leo>pip3 install numpy —no-cache-dir
Collecting numpy
Downloading https://files.pythonhosted.org/packages/93/48/956b9dcdddfcedb1705839280e02cbfeb2861ed5d7f59241210530867d5b/numpy-1.16.3.zip (5.1MB)
|████████████████████████████████| 5.1MB 3.2MB/s
Building wheels for collected packages: numpy
Building wheel for numpy (setup.py) … error
ERROR: Complete output from command ‘c:\users\leo\appdata\local\programs\python\python38\python.exe’ -u -c ‘import setuptools, tokenize;file='»‘»‘C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy\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\Leo\AppData\Local\Temp\pip-wheel-otjo0nri’ —python-tag cp38:
ERROR: Running from numpy source directory.
C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy\numpy\distutils\misc_util.py:476: SyntaxWarning: «is» with a literal. Did you mean «==»?
return is_string(s) and (‘*’ in s or ‘?’ is s)
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\leo\appdata\local\programs\python\python38\lib’, ‘C:\’, ‘c:\users\leo\appdata\local\programs\python\python38\libs’]
NOT AVAILABLE

blis_info:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries blis not found in [‘c:\users\leo\appdata\local\programs\python\python38\lib’, ‘C:\’, ‘c:\users\leo\appdata\local\programs\python\python38\libs’]
NOT AVAILABLE

openblas_info:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries openblas not found in [‘c:\users\leo\appdata\local\programs\python\python38\lib’, ‘C:\’, ‘c:\users\leo\appdata\local\programs\python\python38\libs’]
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
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries tatlas not found in [‘c:\users\leo\appdata\local\programs\python\python38\lib’, ‘C:\’, ‘c:\users\leo\appdata\local\programs\python\python38\libs’]
NOT AVAILABLE

atlas_3_10_blas_info:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries satlas not found in [‘c:\users\leo\appdata\local\programs\python\python38\lib’, ‘C:\’, ‘c:\users\leo\appdata\local\programs\python\python38\libs’]
NOT AVAILABLE

atlas_blas_threads_info:
Setting PTATLAS=ATLAS
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries ptf77blas,ptcblas,atlas not found in [‘c:\users\leo\appdata\local\programs\python\python38\lib’, ‘C:\’, ‘c:\users\leo\appdata\local\programs\python\python38\libs’]
NOT AVAILABLE

atlas_blas_info:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries f77blas,cblas,atlas not found in [‘c:\users\leo\appdata\local\programs\python\python38\lib’, ‘C:\’, ‘c:\users\leo\appdata\local\programs\python\python38\libs’]
NOT AVAILABLE

accelerate_info:
NOT AVAILABLE

C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy\numpy\distutils\system_info.py:638: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
self.calc_info()
blas_info:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries blas not found in [‘c:\users\leo\appdata\local\programs\python\python38\lib’, ‘C:\’, ‘c:\users\leo\appdata\local\programs\python\python38\libs’]
NOT AVAILABLE

C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy\numpy\distutils\system_info.py:638: 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.
self.calc_info()
blas_src_info:
NOT AVAILABLE

C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy\numpy\distutils\system_info.py:638: 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.
self.calc_info()
NOT AVAILABLE

‘svnversion’ nÆo ‚ reconhecido como um comando interno
ou externo, um programa oper vel ou um arquivo em lotes.
non-existing path in ‘numpy\distutils’: ‘site.cfg’
lapack_opt_info:
lapack_mkl_info:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries mkl_rt not found in [‘c:\users\leo\appdata\local\programs\python\python38\lib’, ‘C:\’, ‘c:\users\leo\appdata\local\programs\python\python38\libs’]
NOT AVAILABLE

openblas_lapack_info:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries openblas not found in [‘c:\users\leo\appdata\local\programs\python\python38\lib’, ‘C:\’, ‘c:\users\leo\appdata\local\programs\python\python38\libs’]
NOT AVAILABLE

openblas_clapack_info:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries openblas,lapack not found in [‘c:\users\leo\appdata\local\programs\python\python38\lib’, ‘C:\’, ‘c:\users\leo\appdata\local\programs\python\python38\libs’]
NOT AVAILABLE

atlas_3_10_threads_info:
Setting PTATLAS=ATLAS
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries tatlas,tatlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries lapack_atlas not found in C:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries tatlas,tatlas not found in C:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries tatlas,tatlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
<class ‘numpy.distutils.system_info.atlas_3_10_threads_info’>
NOT AVAILABLE

atlas_3_10_info:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries satlas,satlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries lapack_atlas not found in C:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries satlas,satlas not found in C:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries satlas,satlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
<class ‘numpy.distutils.system_info.atlas_3_10_info’>
NOT AVAILABLE

atlas_threads_info:
Setting PTATLAS=ATLAS
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries ptf77blas,ptcblas,atlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries lapack_atlas not found in C:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries ptf77blas,ptcblas,atlas not found in C:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries ptf77blas,ptcblas,atlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
<class ‘numpy.distutils.system_info.atlas_threads_info’>
NOT AVAILABLE

atlas_info:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries f77blas,cblas,atlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries lapack_atlas not found in C:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries f77blas,cblas,atlas not found in C:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries f77blas,cblas,atlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
<class ‘numpy.distutils.system_info.atlas_info’>
NOT AVAILABLE

lapack_info:
No module named ‘numpy.distutils._msvccompiler’ in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries lapack not found in [‘c:\users\leo\appdata\local\programs\python\python38\lib’, ‘C:\’, ‘c:\users\leo\appdata\local\programs\python\python38\libs’]
NOT AVAILABLE

C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy\numpy\distutils\system_info.py:638: 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.
self.calc_info()
lapack_src_info:
NOT AVAILABLE

C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy\numpy\distutils\system_info.py:638: 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.
self.calc_info()
NOT AVAILABLE

c:\users\leo\appdata\local\programs\python\python38\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: ‘define_macros’
warnings.warn(msg)
running bdist_wheel
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
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
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: Failed building wheel for numpy
Running setup.py clean for numpy
ERROR: Complete output from command ‘c:\users\leo\appdata\local\programs\python\python38\python.exe’ -u -c ‘import setuptools, tokenize;file='»‘»‘C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy\setup.py'»‘»‘;f=getattr(tokenize, ‘»‘»‘open'»‘»‘, open)(file);code=f.read().replace(‘»‘»‘\r\n'»‘»‘, ‘»‘»‘\n'»‘»‘);f.close();exec(compile(code, file, ‘»‘»‘exec'»‘»‘))’ clean —all:
ERROR: Running from numpy source directory.

setup.py clean is not supported, use one of the following instead:

- `git clean -xdf` (cleans all files)
- `git clean -Xdf` (cleans all versioned files, doesn't touch
                    files that aren't checked into the git repo)

Add --force to your command to use it anyway if you must (unsupported).


ERROR: Failed cleaning build dir for numpy
Failed to build numpy
Installing collected packages: numpy
Running setup.py install for numpy … error
ERROR: Complete output from command ‘c:\users\leo\appdata\local\programs\python\python38\python.exe’ -u -c ‘import setuptools, tokenize;file='»‘»‘C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\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\Leo\AppData\Local\Temp\pip-record-sy0t4ryb\install-record.txt’ —single-version-externally-managed —compile:
ERROR: 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_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\\leo\\appdata\\local\\programs\\python\\python38\\lib', 'C:\\', 'c:\\users\\leo\\appdata\\local\\programs\\python\\python38\\libs']
  NOT AVAILABLE

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

openblas_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries openblas not found in ['c:\\users\\leo\\appdata\\local\\programs\\python\\python38\\lib', 'C:\\', 'c:\\users\\leo\\appdata\\local\\programs\\python\\python38\\libs']
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
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries tatlas not found in ['c:\\users\\leo\\appdata\\local\\programs\\python\\python38\\lib', 'C:\\', 'c:\\users\\leo\\appdata\\local\\programs\\python\\python38\\libs']
  NOT AVAILABLE

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

atlas_blas_threads_info:
Setting PTATLAS=ATLAS
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries ptf77blas,ptcblas,atlas not found in ['c:\\users\\leo\\appdata\\local\\programs\\python\\python38\\lib', 'C:\\', 'c:\\users\\leo\\appdata\\local\\programs\\python\\python38\\libs']
  NOT AVAILABLE

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

accelerate_info:
  NOT AVAILABLE

C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy\numpy\distutils\system_info.py:638: UserWarning:
    Atlas (http://math-atlas.sourceforge.net/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [atlas]) or by setting
    the ATLAS environment variable.
  self.calc_info()
blas_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries blas not found in ['c:\\users\\leo\\appdata\\local\\programs\\python\\python38\\lib', 'C:\\', 'c:\\users\\leo\\appdata\\local\\programs\\python\\python38\\libs']
  NOT AVAILABLE

C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy\numpy\distutils\system_info.py:638: 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.
  self.calc_info()
blas_src_info:
  NOT AVAILABLE

C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy\numpy\distutils\system_info.py:638: 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.
  self.calc_info()
  NOT AVAILABLE

'svnversion' nÆo ‚ reconhecido como um comando interno
ou externo, um programa oper vel ou um arquivo em lotes.
non-existing path in 'numpy\\distutils': 'site.cfg'
lapack_opt_info:
lapack_mkl_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries mkl_rt not found in ['c:\\users\\leo\\appdata\\local\\programs\\python\\python38\\lib', 'C:\\', 'c:\\users\\leo\\appdata\\local\\programs\\python\\python38\\libs']
  NOT AVAILABLE

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

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

atlas_3_10_threads_info:
Setting PTATLAS=ATLAS
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries tatlas,tatlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries tatlas,tatlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries tatlas,tatlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
<class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
  NOT AVAILABLE

atlas_3_10_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries satlas,satlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries satlas,satlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries satlas,satlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
<class 'numpy.distutils.system_info.atlas_3_10_info'>
  NOT AVAILABLE

atlas_threads_info:
Setting PTATLAS=ATLAS
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries ptf77blas,ptcblas,atlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries ptf77blas,ptcblas,atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries ptf77blas,ptcblas,atlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
<class 'numpy.distutils.system_info.atlas_threads_info'>
  NOT AVAILABLE

atlas_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries f77blas,cblas,atlas not found in c:\users\leo\appdata\local\programs\python\python38\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries f77blas,cblas,atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries f77blas,cblas,atlas not found in c:\users\leo\appdata\local\programs\python\python38\libs
<class 'numpy.distutils.system_info.atlas_info'>
  NOT AVAILABLE

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

C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy\numpy\distutils\system_info.py:638: 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.
  self.calc_info()
lapack_src_info:
  NOT AVAILABLE

C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy\numpy\distutils\system_info.py:638: 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.
  self.calc_info()
  NOT AVAILABLE

c:\users\leo\appdata\local\programs\python\python38\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'define_macros'
  warnings.warn(msg)
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 «‘c:\users\leo\appdata\local\programs\python\python38\python.exe’ -u -c ‘import setuptools, tokenize;file='»‘»‘C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\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\Leo\AppData\Local\Temp\pip-record-sy0t4ryb\install-record.txt’ —single-version-externally-managed —compile» failed with error code 1 in C:\Users\Leo\AppData\Local\Temp\pip-install-cy037osi\numpy`

I have a very similar question to this question, but I am still one step behind. I have only one version of Python 3 installed on my Windows 7 (sorry) 64-bit system.

I installed NumPy following this link — as suggested in the question. The installation went fine but when I execute

import numpy

I got the following error:

Import error: No module named numpy

Peter Mortensen's user avatar

asked Oct 19, 2011 at 8:54

Seb's user avatar

4

You can simply use

pip install numpy

Or for python3, use

pip3 install numpy

Daniel Patru's user avatar

answered Feb 18, 2016 at 8:51

Andrei Madalin Butnaru's user avatar

12

Installing Numpy on Windows

  1. Open Windows command prompt with administrator privileges (quick method: Press the Windows key. Type «cmd». Right-click on the
    suggested «Command Prompt» and select «Run as Administrator)
  2. Navigate to the Python installation directory’s Scripts folder using the «cd» (change directory) command. e.g. «cd C:\Program Files (x86)\PythonXX\Scripts»

This might be: C:\Users\\AppData\Local\Programs\Python\PythonXX\Scripts or C:\Program Files (x86)\PythonXX\Scripts (where XX represents the Python version number), depending on where it was installed. It may be easier to find the folder using Windows explorer, and then paste or type the address from the Explorer address bar into the command prompt.

  1. Enter the following command: «pip install numpy».

You should see something similar to the following text appear as the package is downloaded and installed.

Collecting numpy
  Downloading numpy-1.13.3-2-cp27-none-win32.whl (6.7MB)  
  100% |################################| 6.7MB 112kB/s
Installing collected packages: numpy
Successfully installed numpy-1.13.3

MechtEngineer's user avatar

answered Nov 13, 2017 at 3:10

harshitha yendapally's user avatar

I think there are something wrong with the installation of numpy.
Here are my steps to solve this problem.

  1. go to this website to download correct package: http://sourceforge.net/projects/numpy/files/
  2. unzip the package
  3. go to the document
  4. use this command to install numpy: python setup.py install

legoscia's user avatar

legoscia

39.7k22 gold badges116 silver badges167 bronze badges

answered Dec 9, 2013 at 15:49

Haimei's user avatar

HaimeiHaimei

12.6k3 gold badges50 silver badges36 bronze badges

1

I also had this problem (Import Error: No module named numpy) but in my case it was a problem with my PATH variables in Mac OS X. I had made an earlier edit to my .bash_profile file that caused the paths for my Anaconda installation (and others) to not be added properly.

Just adding this comment to the list here in case other people like me come to this page with the same error message and have the same problem as I had.

Mamad Farrahi's user avatar

answered May 2, 2015 at 18:17

Bill's user avatar

BillBill

10.4k10 gold badges62 silver badges86 bronze badges

2

You can try:

py -3 -m  pip install anyPackageName

In your case use:

py -3 -m  pip install numpy

vvvvv's user avatar

vvvvv

25.7k19 gold badges50 silver badges81 bronze badges

answered Sep 14, 2019 at 5:14

Clinton Roy's user avatar

Clinton RoyClinton Roy

2,6792 gold badges10 silver badges7 bronze badges

1

You should try to install numpy using one of those:

pip install numpy
pip2 install numpy
pip3 install numpy

For some reason in my case pip2 solved the problem

answered Feb 13, 2020 at 20:16

Ateik's user avatar

AteikAteik

2,4584 gold badges39 silver badges59 bronze badges

Faced with same issue

ImportError: No module named numpy

So, in our case (we are use PIP and python 2.7) the solution was SPLIT pip install commands :

From

RUN pip install numpy scipy pandas sklearn

TO

RUN pip install numpy scipy
RUN pip install pandas sklearn

Solution found here : https://github.com/pandas-dev/pandas/issues/25193, it’s related latest update of pandas to v0.24.0

answered Feb 12, 2019 at 13:39

Nigrimmist's user avatar

NigrimmistNigrimmist

10.4k4 gold badges52 silver badges53 bronze badges

1

I had this problem too after I installed Numpy. I solved it by just closing the Python interpreter and reopening. It may be something else to try if anyone else has this problem, perhaps it will save a few minutes!

answered Mar 15, 2012 at 20:54

Chet's user avatar

ChetChet

21.4k10 gold badges40 silver badges58 bronze badges

I had numpy installed on the same environment both by pip and by conda, and simply removing and reinstalling either was not enough.

I had to reinstall both.

I don’t know why it suddenly happened, but the solution was

pip uninstall numpy

conda uninstall numpy

uninstalling from conda also removed torch and torchvision.

then

conda install pytorch-cpu torchvision-cpu -c pytorch

and

pip install numpy

this resolved the issue for me.

answered Dec 22, 2018 at 12:56

Gulzar's user avatar

GulzarGulzar

23.7k27 gold badges116 silver badges205 bronze badges

1

I too faced the above problem with phyton 3 while setting up python for machine learning.

I followed the below steps :-

Install python-2.7.13.msi

• set PATH=C:\Python27

• set PATH=C:\Python27\Scripts

Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

Downloaded:- — numpy-1.13.1+mkl-cp27-cp27m-win32.whl

          --scipy-0.18.0-cp27-cp27m-win32.whl 

Installing numpy:
pip install numpy-1.13.1+mkl-cp27-cp27m-win32.whl

Installing scipy:
pip install scipy-0.18.0-cp27-cp27m-win32.whl

You can test the correctness using below cmds:-

>>> import numpy
>>> import scipy
>>> import sklearn
>>> numpy.version.version
'1.13.1'
>>> scipy.version.version
'0.19.1'
>>>

answered Sep 27, 2017 at 5:58

Vikram S's user avatar

Vikram SVikram S

5515 silver badges5 bronze badges

For those using python 2.7, should try:

apt-get install -y python-numpy

Instead of pip install numpy

answered Jul 29, 2019 at 19:05

georgeos's user avatar

georgeosgeorgeos

2,3512 gold badges24 silver badges28 bronze badges

0

I’m not sure exactly why I was getting the error, but pip3 uninstall numpy then pip3 install numpy resolved the issue for me.

answered Feb 25, 2017 at 14:12

Clay H's user avatar

Clay HClay H

6519 silver badges21 bronze badges

1

Those who are using xonsh, do xpip install numpy.

answered Feb 15, 2018 at 4:36

Necktwi's user avatar

NecktwiNecktwi

2,5137 gold badges39 silver badges63 bronze badges

For installing NumPy via Anaconda(use below commands):

  • conda install -c conda-forge numpy
  • conda install -c conda-forge/label/broken numpy

answered Nov 1, 2017 at 4:32

Rashmi Nagpal's user avatar

import numpy as np
ImportError: No module named numpy 

I got this even though I knew numpy was installed and unsuccessfully tried all the advice above. The fix for me was to remove the as np and directly refer to modules . (python 3.4.8 on Centos)
.

import numpy
DataTwo=numpy.stack((OutputListUnixTwo))...

answered Jun 29, 2018 at 12:35

zzapper's user avatar

zzapperzzapper

4,7435 gold badges48 silver badges45 bronze badges

For me, on windows 10, I had unknowingly installed multiple python versions (One from PyCharm IDE and another from Windows store). I uninstalled the one from windows Store and just to be thorough, uninstalled numpy pip uninstall numpy and then installed it again pip install numpy. It worked in the terminal in PyCharm and also in command prompt.

answered May 15, 2020 at 4:07

Shubhzgang's user avatar

ShubhzgangShubhzgang

3222 silver badges9 bronze badges

this is the problem of the numpy’s version, please check out $CAFFE_ROOT/python/requirement.txt. Then exec: sudo apt-get install python-numpy>=x.x.x, this problem will be sloved.

answered May 11, 2016 at 15:18

zhangyi's user avatar

1

I did everything from the answers here but nothing worked. So I deleted all the previous installations of numpy using the commands below.

sudo rm -rf /usr/lib/python3/dist-packages/numpy*
sudo rm -rf /usr/lib/python3.7/dist-packages/numpy*
sudo rm -rf /usr/lib/python2.7/dist-packages/numpy*

Then just install using pip3.

sudo pip3 install numpy

Dharman's user avatar

Dharman

31.1k25 gold badges86 silver badges137 bronze badges

answered Apr 28, 2021 at 9:11

Noman's user avatar

NomanNoman

215 bronze badges

Run

conda update --all

PS recall calling python using either «python2» or «python3» (not merely «python»).

answered Oct 18, 2021 at 5:16

Itamar cohen's user avatar

solution for me — I installed numpy inside a virtual environment, but then running ipython was not inside virtual env:

(venv) ➜  which python
/Users/alon/code/google_photos_project/venv/bin/python
(venv) ➜  which ipython
/usr/bin/ipython

so I had to install ipython, and run ipython from the venv like this:

python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'

answered Aug 26, 2020 at 3:33

Alon Gouldman's user avatar

I was trying to use NumPy in Intellij but was facing the same issue so, I figured out that NumPy also comes with pandas. So, I installed pandas with IntelliJ tip and later on was able to import NumPy. Might help someone someday!

answered Aug 31, 2020 at 8:38

whatsinthename's user avatar

As stated in other answers, this error may refer to using the wrong python version. In my case, my environment is Windows 10 + Cygwin. In my Windows environment variables, the PATH points to C:\Python38 which is correct, but when I run my command like this:

./my_script.py

I got the ImportError: No module named numpy because the version used in this case is Cygwin’s own Python version even if PATH environment variable is correct.
All I needed was to run the script like this:

py my_script.py

And this way the problem was solved.

answered Sep 4, 2020 at 23:26

Metafaniel's user avatar

MetafanielMetafaniel

29.4k8 gold badges40 silver badges67 bronze badges

Try uninstalling and then reinstalling the Python extension for VSCode.

I tried many different solutions, but this «hard refresh» was the only one that worked for me.

answered Apr 14, 2021 at 10:48

Ole August Støle's user avatar

I just had the same problem as well! It turns out the problem happens when you’re installing Numpy to a version of python and trying to run the program using another python version. Probably the global version of Python your text editor opens by default is different from the one that you need for the version of numpy you are running.

So to start off, run:

which python
python --version
which pip
pip list

If you can find numpy on the list, its most likely the python version you are using is not compatible with the version of numpy installed. Try switching to a different version of Python in this case.

If numpy is not installed just pip install numpy or pip3 install numpy depending upon your version of python.

answered May 25, 2021 at 17:16

Rishabh's user avatar

RishabhRishabh

812 silver badges8 bronze badges

0

On MacOs, if you are getting this error in Pycharm and you installed Python3 and NumPy through Homebrew, the python interpreter path is probably not pointing to the Python interpreter that is installed by Homebrew. In Pycharm, go to Preferences>Project: [Project Name]>Python Interpreter, and enter /opt/homebrew/bin/python3 for the path to python interpreter.

answered Apr 27, 2022 at 3:50

Farid Rahmani's user avatar

In this article, we will discuss how to fix the No module named numpy using Python.

Numpy is a module used for array processing. The error “No module named numpy ” will occur when there is no NumPy library in your environment i.e. the NumPy module is either not installed or some part of the installation is incomplete due to some interruption. We will discuss how to overcome this error.

In Python, we will use pip function to install any module

Syntax:

pip install module_name

Example: How to install NumPy

pip install numpy

Output:

Collecting numpy

  Downloading numpy-3.2.0.tar.gz (281.3 MB)

     |████████████████████████████████| 281.3 MB 9.7 kB/s 

Collecting py4j==0.10.9.2

  Downloading py4j-0.10.9.2-py2.py3-none-any.whl (198 kB)

     |████████████████████████████████| 198 kB 52.8 MB/s 

Building wheels for collected packages: numpy

  Building wheel for numpy (setup.py) … done

  Created wheel for numpy: filename=numpy-3.2.0-py2.py3-none-any.whl size=281805912 sha256=c6c9edb963f9a25f31d11d88374ce3be6b3c73ac73ac467ef40b51b5f4eca737

  Stored in directory: /root/.cache/pip/wheels/0b/de/d2/9be5d59d7331c6c2a7c1b6d1a4f463ce107332b1ecd4e80718

Successfully built numpy

Installing collected packages: py4j, numpy

Successfully installed py4j-0.10.9.2 numpy-3.2.0

We can verify by again typing same command then output will be:

Output:

Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (1.1.5)

To get the numpy description like the current version in our environment we can use show command  

Example: To get NumPy description 

pip show numpy

Output:

Name: numpy

Version: 1.19.5

Summary: NumPy is the fundamental package for array computing with Python.

Home-page: https://www.numpy.org

Author: Travis E. Oliphant et al.

Author-email: None

License: BSD

Location: /usr/local/lib/python3.7/dist-packages

Requires: 

Required-by: yellowbrick, xgboost, xarray, wordcloud, torchvision, torchtext, tifffile, thinc, Theano-PyMC, tensorflow, tensorflow-probability, tensorflow-hub, tensorflow-datasets, tensorboard, tables, statsmodels, spacy, sklearn-pandas, seaborn, scs, scipy, scikit-learn, scikit-image, resampy, qdldl, PyWavelets, python-louvain, pystan, pysndfile, pymc3, pyerfa, pyemd, pyarrow, plotnine, patsy, pandas, osqp, opt-einsum, opencv-python, opencv-contrib-python, numexpr, numba, nibabel, netCDF4, moviepy, mlxtend, mizani, missingno, matplotlib, matplotlib-venn, lightgbm, librosa, Keras-Preprocessing, kapre, jpeg4py, jaxlib, jax, imgaug, imbalanced-learn, imageio, hyperopt, holoviews, h5py, gym, gensim, folium, fix-yahoo-finance, fbprophet, fastprogress, fastdtw, fastai, fa2, ecos, daft, cvxpy, cufflinks, cmdstanpy, cftime, Bottleneck, bokeh, blis, autograd, atari-py, astropy, arviz, altair, albumentations

The installation remains same for all other operating systems and software just the platform changes. If our installation is successful any NumPy code will work fine 

Example: Program to create a NumPy array and display

Python3

import numpy

data = numpy.array([1, 2, 3, 4, 5])

data

Output:

array([1, 2, 3, 4, 5])

Last Updated :
19 Dec, 2021

Like Article

Save Article

Понравилась статья? Поделить с друзьями:

Интересное по теме:

  • Pixma g2400 ошибка 5200
  • Pip install mysql python ошибки
  • Pips installer ошибка при обновлении
  • Pip install json ошибка
  • Pip ошибка при установке пакетов

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии