Cannot find numpy module - python

I am trying to run a python file which needs numpy as an import.
I have set up an environment where numpy is installed via Anaconda. I am also using pypy, and when I try to run the file using
pypy myFile.py
I get the following error
ImportError: No module named numpy
I then run pip list to check the packages currently installed in the enivornment and numpy is there
certifi 2018.11.29
mkl-fft 1.0.10
mkl-random 1.0.2
numpy 1.15.4
pip 19.0.1
setuptools 40.8.0
wheel 0.32.3
wincertstore 0.2
I'm not sure why it is not finding numpy, any help is appreciated, thanks

If you used conda to install Numpy, you probably installed a version that is not compatible with pypy. Use pip instead. Jump into your virtual environment and:
conda uninstall numpy
pip install numpy

Related

Conda installs a package that already exists

Although I already have numpy installed in my anaconda environment as per conda list
numpy 1.15.4 pypi_0 pypi
numpy-base 1.16.2 py36hc3f5095_0
numpydoc 0.8.0 py36_0
However, when I did conda install theano, it tries to install another numpy package with the same version as shown below
added / updated specs:
- theano
The following NEW packages will be INSTALLED:
mkl_fft pkgs/main/win-64::mkl_fft-1.0.10-py36h14836fe_0
numpy pkgs/main/win-64::numpy-1.16.2-py36h19fb1c0_0
pygpu pkgs/main/win-64::pygpu-0.7.6-py36h452e1ab_0
scipy pkgs/main/win-64::scipy-1.2.1-py36h29ff71c_0
theano pkgs/main/win-64::theano-1.0.3-py36_0
My questions are:
why do I have different versions of numpy (numpy 1.15.4 and numpy-base 1.16.2)?
why does anaconda want to install a second numpy package of the same version in its environment?
Thanks.
why do I have different versions of numpy (numpy 1.15.4 and numpy-base 1.16.2)?
If you open Conda terminal and from numpy import __version__ you will probably see that the version is equal to 1.16.2. But if you open python externally to the Conda, and do the same thing you will probably see the version 1.15.4. Conda by default maintains the base environment and, as each environment can have its own version of each module, the difference is because of that.
why does anaconda want to install a second numpy package of the same
version in its environment?
This can be explained if you have another active environment (different from the base environment), and the first answer also answers this.

Numpy: import error for python2.7 after get-apt upgrade

Today, I have decided to upgrade my software packages:
sudo apt-get upgrade
After that, I am trying to launch my python2 code and the error appears:
ImportError: No module named numpy
I have tried pip install numpy, but got a message
Requirement already satisfied: numpy in /home/user/anaconda3/lib/python3.5/site-packages (1.15.1)
pip2 install numpy produces an exception:
pkg_resources.VersionConflict: (pip 18.0 (/usr/local/lib/python3.5/dist-packages), Requirement.parse('pip==8.1.1'))
conda install numpy results in
# All requested packages already installed.
which python gives me
/home/user/anaconda3/bin/python
which pip results in
/home/user/anaconda3/bin/pip
What could be the problem? Seems like numpy cannot be installed for python2 because it is already installed for python3. I suppose, something went wrong with python2 vs python3 linkage in conda? Is it a problem with python, numpy, pip, conda or environments?

OpenCV install: deprecation error

I would like to use opencv with python, but I think I have a problem with my numpy version.
How can I make sure that opencv uses the right numpy version?
I did
sudo pip install opencv-python
And I received this message
Installing collected packages: numpy, opencv-python
Found existing installation: numpy 1.8.0rc1
DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling numpy-1.8.0rc1:
Successfully uninstalled numpy-1.8.0rc1
Successfully installed numpy-1.14.5 opencv-python-3.4.1.15
Now when I try
import cv2
I get
ImportError: numpy.core.multiarray failed to import
I also updated my numpy version with
sudo pip install -U numpy
If you are using both Py2.7 and 3.5 on your machine, make sure numpy is being installed for the correct version by doing either python3 -m pip install numpy -I
or python2 -m pip install numpy -I

Uninstallation issues in python numpy

I am in the process of downgrading numpy1.13 to 1.7. In order to do this, I am uninstalling the latest version so that i can install with a older version,
I have uninstalled numpy in anaconda python using
`pip uninstall numpy`
After uninstalling, when i see the conda list, numpy is still listed in the library list.
When i tried again with pip uninstall numpy, its throwing me an errors as "cannot uninstall requirement numpy, not installed".`
Any help on this is much appreciated.
Thank you .
try this if you are using anaconda:
conda uninstall numpy
conda install numpy=1.7
or this if you are using python pip:
pip uninstall numpy
pip install numpy==1.7
The following commands works for me to uninstall
pip3 uninstall numpy
pip uninstall numpy
Then, for installing
pip install numpy
Anaconda is a package manager for python, you can install in anaconda environment either by conda or by pip. Uninstalling a package depends on how you installed the package.
When you run the conda list command yo get output like below
# packages in environment at C:\Anaconda3\envs\base:
#
# Name Version Build Channel
astroid 2.4.2 pypi_0 pypi
ca-certificates 2020.6.20 hecda079_0 conda-forge
certifi 2020.6.20 py36h9f0ad1d_0
colorama 0.4.3 pypi_0 pypi
django 2.2 py36_0
djangorestframework 3.11.0 py_0 conda-forge
libblas 3.8.0 15_mkl conda-forge
numpy 1.18.4 py36h4d86e3b_0 conda-forge
openssl 1.1.1g he774522_0 conda-forge
you can check the channel from which you have installed the dependency. If you installed a package via conda it is safe to uninstall using conda only

How to install Numpy & Scipy for Python 3.3 on Moutain Lion

Haven't found a working solution as of yet. I have three different versions of Python on my system, the default bundled with OSX (2.7.2), 2.7.3 installed via homebrew and 3.3.0 installed via homebrew. Running pip install numpy or pip install scipy will install it for the 2.7.3 version.
How can I install numpy and scipy for Python 3.3.0 on Moutain Lion?
you need to call pip3 instead of pip. Homebrew installs pip3 with python3.
I just tried pip3 install numpy on my OSX 10.7.5 python 3.3.0 machine and it failed. It looks like numpy v1.6 is not compatible but numpy v1.7 (beta, not available via pip3) is.
Link: A post on SO:
Why does installing numpy using pip fail while building directly does not

Categories