No matching distribution found for numpy (from torch==1.10) - python

Working on Ubuntu 18.04 in a VM.
I have python3 installed at /usr/bin/python3.6 according to whereis python3.
When I run pip3 freeze, I see numpy installed, with version 1.15.4, and when I enter into python3 console, I can import numpy as np perfectly fine with no errors.
What I am trying to do now is to install PyTorch, specifically torch==1.1.0, without GPU / CUDA.
I got the following installation instructions from https://pytorch.org/get-started/locally/:
pip3 install https://download.pytorch.org/whl/cpu/torch-1.1.0-cp36-cp36m-linux_x86_64.whl
pip3 install https://download.pytorch.org/whl/cpu/torchvision-0.3.0-cp36-cp36m-linux_x86_64.whl
I downloaded these wheel files, and tried to run them from local directory as such:
/usr/bin/python3.6 -m pip install ~/Desktop/torch-1.1.0-cp36-cp36m-linux_x86_64.whl
and got the following error:
No matching distribution found for numpy (from torch==1.1.0)
I don't understand why this is the case, cause my numpy library is clearly already installed and working (READ ABOVE: I am able to import numpy in python3 console). Also, I had no issues installing PyTorch with GPU on my Windows machine, with torch 1.1.0 and numpy 1.15.4.
Alternatively, I tried to build PyTorch from source by moving into the PyTorch source directory and executing /usr/bin/python3 setup.py install, but it didn't work since I am not using a GPU, and CUDA is not installed. I am not able to find instructions on how I can build PyTorch from source without GPU in a Linux environment?
Can anyone kindly advise? Thank you!
Some additional information
(1) Tried to install PyTorch with the --no-dependencies flag as suggested by #Jan, and it installed, but I am not sure if Torch will really work perfectly.
(2) which pip3 points to /usr/bin/pip3
(3) pip3 show numpy tells me that the location is at /home/name/.local/lib/python3.6/site-packages

If you are sure that all dependencies are manually installed, you could try --no-dependencies flag for pip3. Otherwise, I would point you to Anaconda as python environment provider, it is pretty convenient.

Since it would seem that pip works correctly, you could try creating a virtual environment using venv and install things from there.
I tested it on my machine (Ubuntu 18.04) and I installed torch successfully without CUDA by launching the same commands that you used, but in the virtualenv.
Just make sure that once you activate the environment, which python and which pip point to those in the env (i.e NOT /usr/bin/, but most likely in /home/<user>/<venv_name>/bin/python).
Edit:
Here are the steps I followed:
1) Install virtualenv with:
python3 -m pip install --user virtualenv
2) create a virtualenv named nogpu-venv (or whatever) with:
python3 -m venv nogpu-venv
This will create a folder where you launched the command named nogpu-venv.
3) Then activate the venv with source nogpu-venv/bin/activate.
You should see (nogpu-venv) to the left of your name in the terminal. Also, the commands which python and which pip should point to the respective files in the nogpu-venv.
4) Install torch with:
pip3 install https://download.pytorch.org/whl/cpu/torch-1.1.0-cp36-cp36m-linux_x86_64.whl
pip3 install https://download.pytorch.org/whl/cpu/torchvision-0.3.0-cp36-cp36m-linux_x86_64.whl
Hope it helps!

Related

Ubuntu conda Python3.9 can not find numpy

I can not use Mumpy with Ubuntu, Python 3.9 in Anaconda. But I have installed it. How can I fix this?
Part of the point of virtual environments, like those created by conda, are that you don't need root ("administrator") privileges to build and install software, so you shouldn't need sudo; just run python setup.py develop. You may need other things installed (compilers and development libraries) for that to work.
You've already confirmed numpy is installed via your conda install and pip install commands, but you could also run python -c "import numpy; print(numpy.__version__)" as further confirmation that it's working.
Pytorch is already packaged for conda - have you tried the command listed at that link?

No module named 'numpy' [duplicate]

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
You can simply use
pip install numpy
Or for python3, use
pip3 install numpy
Support for Python 3 was added in NumPy version 1.5.0, so to begin with, you must download/install a newer version of NumPy.
Or simply using pip:
python3 -m pip install numpy
Installing Numpy on Windows
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)
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.
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
I think there are something wrong with the installation of numpy.
Here are my steps to solve this problem.
go to this website to download correct package: http://sourceforge.net/projects/numpy/files/
unzip the package
go to the document
use this command to install numpy: python setup.py install
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.
You can try:
py -3 -m pip install anyPackageName
In your case use:
py -3 -m pip install numpy
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
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
You installed the Numpy Version for Python 2.6 - so you can only use it with Python 2.6. You have to install Numpy for Python 3.x, e.g. that one: http://sourceforge.net/projects/numpy/files/NumPy/1.6.1/numpy-1.6.1-win32-superpack-python3.2.exe/download
For an overview of the different versions, see here: http://sourceforge.net/projects/numpy/files/NumPy/1.6.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!
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.
For those using python 2.7, should try:
apt-get install -y python-numpy
Instead of pip install numpy
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'
>>>
I'm not sure exactly why I was getting the error, but pip3 uninstall numpy then pip3 install numpy resolved the issue for me.
Those who are using xonsh, do xpip install numpy.
For installing NumPy via Anaconda(use below commands):
conda install -c conda-forge numpy
conda install -c conda-forge/label/broken numpy
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))...
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.
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.
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
Run
conda update --all
PS recall calling python using either "python2" or "python3" (not merely "python").
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()'
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!
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.
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.
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.
For whom installation target is Raspberry Pi, as here they suggest:
sudo apt-get install libatlas-base-dev
could be working.
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.

running python script on HPC [duplicate]

Since yesterday I've had this error when I try to import packages on anaconda :
ImportError: Missing required dependencies ['numpy']
I have tried un-installing Anaconda and Python, switching to Python 2.7 but nothing works it's still the same error, here is the code I get :
Any help is really appreciated thanks !
I had this same issue immediately after upgrading pandas to 0.19.2. I fixed it with the following install/uninstall sequence from the windows cmd line:
pip uninstall pandas -y
pip uninstall numpy -y
pip install pandas
pip install numpy
This also broke my matplotlib install so I uninstalled/installed that as well.
Very odd behavior for a seemingly routine upgrade.
What happens if you try to import numpy?
Have you tried'
pip install --upgrade numpy
pip install --upgrade pandas
I had to install this other package:
sudo apt-get install libatlas-base-dev
Seems like it is a dependency for numpy but the pip or apt-get don't install it automatically for whatever reason.
I had this problem with last version of numpy 1.16.x
Problem resolved with
python3 -m pip uninstall numpy
python3 -m pip install numpy==1.14.0
Did you install miniconda and pandas without dependencies?
Try installing numpy first with conda install numpy or pip install numpy.
If you're on Windows you can get pre-compiled versions of most libraries that require compilation from here.
On Windows 10 Anaconda3-5.3.0-Windows-x86_64 I had the Missing required dependencies ['numpy'] error when running scripts as so, %HOMEPATH%\AppData\Local\Continuum\anaconda3\python.exe pandas_script_foo.py.
In my case the error was caused by missing Anaconda package PATH definitions when running Anaconda python.exe in a windows cmd.exe session. The numpy package is not missing. It just can't be found on the PATH.
The Anaconda installation includes windows shortcuts that give examples of configuring the PATH per script run. See the shortcuts in the %HOMEPATH%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit) directory for examples.
See the %HOMEPATH%\AppData\Local\Continuum\anaconda3\cwp.py script to see how Anaconda configures PATH.
Below is an example windows BAT file that calls cwp.py to setup PATH, and then run a python script. Its a copy of the commands the Anaconda jupyter-lab shortcut executes.
%HOMEPATH%\AppData\Local\Continuum\anaconda3\python.exe ^
%HOMEPATH%\AppData\Local\Continuum\anaconda3\cwp.py ^
%HOMEPATH%\AppData\Local\Continuum\anaconda3 ^
%HOMEPATH%\AppData\Local\Continuum\anaconda3\python.exe ^
%HOMEPATH%\AppData\Local\Continuum\anaconda3\Scripts\jupyter-lab-script.py
If you need to execute python scripts on Anaconda with the conveniance of running a BAT file, the above BAT file example should do the trick.
The data manipulation capabilities of pandas are built on top of the numpy library. In a way, numpy is a dependency of the pandas library. If you want to use pandas, you have to make sure you also have numpy. When you install pandas using pip, it automatically installs numpy. If it doesn't, try the following
pip install -U numpy pandas
For conda
conda install numpy pandas
I also faced the same issue. It happened to me after I upgraded my numpy library.
It was resolved in my case by upgrading my pandas library as well after upgrading my numpy library using the below command:
pip install --upgrade pandas
Try:
sudo apt-get install libatlas-base-dev
It should work now.
Else, try uninstall and reinstall numpy and pandas.
I had the same issue. It was because I had multiple versions of numpy installed. Remove all versions by repeatedly using:
pip uninstall numpy
Then re-install it with the command:
pip install numpy
First, try to import numpy on it's own, like so:
import numpy as np
I got this message:
ImportError: Something is wrong with the numpy installation. While importing
we detected an older version of numpy in
['/home/michael/.local/lib/python3.6/site-packages/numpy']. One method of
fixing this is to repeatedly uninstall numpy until none is found, then
reinstall this version.
So do what it says, keep uninstalling numpy until there is none, and then reinstall.
This worked for me.
I had the same issue while using Microsoft Visual Code with Python 3.7.3 64-bit('base':conda)as my python interpreter. Before running any code type the following three commands:
C:/ProgramData/Anaconda3/Scripts/activate #activate conda Scripts directory
conda activate base #activate conda
& C:/ProgramData/Anaconda3/python.exe #to run python
I have same problem.
I have got two version of numpy 1.16.6 and 1.15.4, fresh installed pandas did not work correctly.
I fixed it by uninstalling all versions of numpy and pandas and install the last versions.
$ pip uninstall numpy pandas -y
Uninstalling numpy-1.16.6:
Successfully uninstalled numpy-1.16.6
Uninstalling pandas-0.24.2:
Successfully uninstalled pandas-0.24.2
$ pip uninstall numpy pandas -y
Uninstalling numpy-1.15.4:
Successfully uninstalled numpy-1.15.4
Cannot uninstall requirement pandas, not installed
$ pip uninstall numpy pandas -y
Cannot uninstall requirement numpy, not installed
$ pip install numpy pandas
I had the same issue with anaconda package, it got updated.
anaconda {4.3.1 -> custom} ## I am not sure if this was the issue
Hit below command to know
conda list --revisions
what i did is just uninstall pandas with conda and re-install it
conda install pandas
Some new libs may also get installed with it.
It worked for me hope will do the same for you.
Uninstall all pip packages that you're having problems with. Manually remove all site-packages files. If you're using MacPorts, sudo port clean .
Then try reinstalling. Sometimes, there are files that should have been removed, but weren't if the installation was abruptly interrupted or something.
There could be an issue with conflicting versions of the package(s), as well as potentially issues with Pathing. Are you sure you've set the correct Path for your binaries? (/opt/local/bin, /anaconda2/bin, etc.)
Another issue could be some PYTHONPATH that's explicitly looking in the wrong place for the file.
I had a same issue recently with Anaconda with Python 3.7.
I solved this problem by downgrading python version to 3.6:
conda install python=3.6
and then by updating all the packages:
conda update --all
pandas is built on top of numpy so you need to have numpy to use the data manipulation feature, so install numpy first.
pip install numpy
This worked in my anaconda environment, but I do not know why conda does not work. For some reason conda uninstall was not sufficient. This only worked with conda remove.
conda remove pandas
conda remove numpy
conda install pip
pip install pandas
*With help from this answer
This raises the following import warning in python 3.6 and 3.7:
ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
If you with to ignore this warning (and maybe other ImportWarnings), add the following to your script before importing pandas:
import warnings
warnings.filterwarnings('ignore', category=ImportWarning, module='_bootstrap.py')
In my case even though I was using the above options of uninstall and installing using pip the code was still giving me same errors.
Finally, I created a vritual environment and Installed numpy and pandas using pip in my virtual env. Now the code is running.
Steps: for Anaconda3 - Please change according to your installation type:
[if you dont have virtual env package installed]
$ pip install virtualenv
[from command prompt go to the directory by c:\anadonda3\scripts
[write the following command to use virtual env to create a virtual env for you in your desired location]
$virtualenv c:\anaconda3\envs\my_virtual_env
[once created you will have to activate your virtual env]
$c:\anaconda3\envs\my_virtual_env\scripts activate
[now pip install numpy and pandas and other required packages using pip]
[once installations are done exit from the virtual env]
$c:\anaconda3\envs\my_virtual_env\scripts deactivate
now use the python.exe inside your virtual env folder to run the script and it will run even with python 3.7.
I am using Win10 and Conda, and this issue just append to me when upgrading python 3.7.2-h8c8aaf0_0 --> 3.7.2-h8c8aaf0_2.
I solved it by return to the previous version with
conda install python=3.7.2=h8c8aaf0_0
If you're running your program on PyCharm on Windows, there is a known bug, because PyCharm simply doesn't add env-related paths to PATH.
The issue is fixed in the 2019.1 Early Access Preview (EAP) build.
For me installing the EAP fixed the issue.
nothing worked for me ... except when I found this
I suspect that you have a local file called unittest.py that is getting imported instead of the standard module.
I was trying to upgrade my anaconda 2 with anaconda 3. I tried installing Anaconda3-2018.12-Windows-x86 and Anaconda3-2019.03-Windows-x86_64 on my Windows 10 machine and failed with this error. For me, using Anaconda3-4.4.0-Windows-x86_64 for anaconda 3 worked the trick after trying everything listed in answers here.
I fixed this using Anaconda by going to Environments > base(root), searching for numpy in the installed modules and clicking the tickbox alongside it and choosing > Mark for specific version installation > 1.14.0 (as suggested by another user on this thread). Then clicking Apply. Once it downgraded numpy I stopped getting errors when running py files on the command line.
Throughout this saga, I was still able to use https://pypi.org/project/auto-py-to-exe/ even when I was getting the numpy errors on the command line, but it was a hassle to create an exe every time I wanted to test a change. It's all sorted now. I guess there was a problem with numpy 1.16.4.
Anyway, I hope this helps someone who's using Anaconda as well.
The following worked for me.
Deleted the folders for numpy and pandas together with their contents completely from the site-packages folder. Check depending on whether you are using python2 or python3. Check the exact path as per your machine.
N.B handle with care "rm -rf" command. If you are not sure of what you are doing, please do it manually using any file explorer of your choice!!
rm -rf ~/anaconda2/envs/myenv/lib/pythonX/site-packages/pandas*
rm -rf ~/anaconda2/envs/myenv/lib/pythonX/site-packages/numpy*
Then i installed clean packages for pandas and numpy as usual with
pip install numpy
pip install pandas
I've got the same error recently. Before applying uninstall or install tools, try to update your Jupyter.
How? Go to 'Environments' and type on the Search Packages box 'pandas'. Afterwards, check the version (if that column shows a blue number with a diagonal arrow, it means that your pandas is out of date). Click on 'pandas' and a option will pop up (choose 'Apply' and wait for a couple of minutes to update the package). And then, make a quick test on any notebook to make sure that your Jupyter is running smoothly.
For those who couldn't solve with the above answers:
Ensure that you are running python3 with
$ python version
If not, install python3.
Then change default python to python3 with
$ alias python=python3
Next, close your jupyter lab/notebook environment and re-launch it with default python being python3.
build_exe_options = {"packages": ["os",'pandas','numpy']}
It works.
you are running python 3.7
create environment for python 3.6
python3.6 filename.py

Problems with installing matplotlib in python 3.6

I'm trying to teach myself python, and I feel out of my depth. To start, I am working on a mac which already comes with python 2.7 installed.
I installed python 3.6 recently and have been using it to teach myself the basics. I'd like to eventually learn how to produce mathematical plots in python, and I know I will need the matplotlib package to do that.
Following some advice online, I was told that python3 already comes with pip installed, which is what I thought I should use to install matplotlib. The advice said I should type the following into the mac terminal:
python3.6 -m pip install matplotlib
I typed this, and it seemed like the package was installing, but I ended up getting some sort of error code that said:
Command "python setup.py egg_info" failed with error code 1 in [folder].
I tried opening IDLE and typing "import matplotlib", but I got the error: "no module named matplotlib". I also tried typing "import matplotlib.pyplot as plt", but I got the same error.
Based on further research and this youtube video, I've decided to just install miniconda in order to have access to the matplotlib package.
The problem is, I'm not sure if I should somehow be uninstalling whatever was installed when I ran the code above to install matplotlib. I've actually run that line of code 3 or 4 times. Should I remove anything before installing miniconda? Also, I am running python 3.6, while miniconda is listed on the website as being for python 3.5. Does this mean it won't work for my version of python?
Running pip like that would install packages system-wide. I'm guessing it's failing because you're not running as root (i.e. the administrator user). But wait! Don't try again as root! Instead of installing packages, do it in a virtual environment. First create it:
virtualenv myenv
This creates a directory called myenv with a bunch of stuff in it (so make note of where you run this command). Whenever you want to use the virtual environment (like straight away!) you first need to activate it:
. myenv/bin/activate
Don't miss out that dot (followed by a space) at the beginning! As the other answer says, the first thing you should do in it is upgrade pip:
pip install --upgrade pip
Now you're ready install whatever else you like:
pip install matplotlib
One last note: The virtual environment is tied to a particular Python version. By default it uses the system's Python 2.7 installation, so to use a different one you need to specify it when you create the virtual environment, like this (if that Python version is installed system-wide):
virtualenv -p python3.5 myenv
Or like this (if that Python version is not installed system-wide):
virtualenv -p /path/to/my/installation/of/python3.5 myenv
While the virtual environment is activated, you don't need to specify the particular path/version of Python. Just run it like this:
python
I also encountered many problems during my installation.
It seems that version 2 of matplotlib is not compatible with Python version 3.
Finally, I succeeded by specifying version 3 of matplotlib as follows with the following command:
sudo apt-get install python3-matplotlib
Reference from the Matplotlib website:
https://matplotlib.org/users/installing.html#building-on-linux
Try upgrade setup tools
--upgrade setuptools
or
easy_install -U setuptools
or upgrade pip
pip install --upgrade pip
I ended up downloading anaconda and using the python interpreter that comes with it, as anaconda comes with matplotlib and many other python packages of interest.
the pip command typically is for the Python 2. use pip3 instead to install the libraries in the python 3.X path
This should work
pip3 install matplotlib
The solution that work for me in python 3.6 is the following
py -m pip install matplotlib
Matplotlib files are downloaded in ~/.local/lib/python3.6/site-packages/ and not in /usr/lib/python3.6/ .
Try the command:
sudo cp -r ~/.local/lib/python3.6/site-packages/* /usr/lib/python3.6/

Error "Import Error: No module named numpy" on Windows

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
You can simply use
pip install numpy
Or for python3, use
pip3 install numpy
Support for Python 3 was added in NumPy version 1.5.0, so to begin with, you must download/install a newer version of NumPy.
Or simply using pip:
python3 -m pip install numpy
Installing Numpy on Windows
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)
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.
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
I think there are something wrong with the installation of numpy.
Here are my steps to solve this problem.
go to this website to download correct package: http://sourceforge.net/projects/numpy/files/
unzip the package
go to the document
use this command to install numpy: python setup.py install
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.
You can try:
py -3 -m pip install anyPackageName
In your case use:
py -3 -m pip install numpy
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
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
You installed the Numpy Version for Python 2.6 - so you can only use it with Python 2.6. You have to install Numpy for Python 3.x, e.g. that one: http://sourceforge.net/projects/numpy/files/NumPy/1.6.1/numpy-1.6.1-win32-superpack-python3.2.exe/download
For an overview of the different versions, see here: http://sourceforge.net/projects/numpy/files/NumPy/1.6.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!
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.
For those using python 2.7, should try:
apt-get install -y python-numpy
Instead of pip install numpy
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'
>>>
I'm not sure exactly why I was getting the error, but pip3 uninstall numpy then pip3 install numpy resolved the issue for me.
Those who are using xonsh, do xpip install numpy.
For installing NumPy via Anaconda(use below commands):
conda install -c conda-forge numpy
conda install -c conda-forge/label/broken numpy
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))...
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.
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.
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
Run
conda update --all
PS recall calling python using either "python2" or "python3" (not merely "python").
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()'
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!
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.
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.
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.
For whom installation target is Raspberry Pi, as here they suggest:
sudo apt-get install libatlas-base-dev
could be working.
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.

Categories