Can't import numpy in python 2.7 - python

When running the following code in python 2.7:
import numpy
I get the result:
ImportError: No module named numpy
I have however got numpy installed for python 2.7, which is seen when running the following in terminal:
pip install numpy
I get the following:
Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Working on macOS10.13.1
What am I missing?
Any help will be greatly appreciated!

have you tried uninstalling the numpy package and re-installing it? As mentioned you may be running python 3 instead of python 2 which could cause this issue.alternatively you could install an api like anaconda which comes with numpy pre-installed this may resolve the missing module. anaconda website: https://www.anaconda.com/download/

Related

Numpy is installed, but astropy says numpy is not installed

An ImportError is thrown when my program searches for Numpy. Yet, numpy is installed as seen by the import numpy working properly.
I've tried
uninstalling python and numpy and reinstalling with choco
with pip
and with conda.
None seem to work. Any suggestions?
Any suggestions?
Does import numpy; print(numpy.__version__) work when you execute c:\agent03_work\s\turo.venv\bin\python.exe ? If not, you need to c:\agent03\_work\s\turo\.venv\bin\pip install numpy and you should be sorted.

No module named 'numpy' but Requirement already satisfied: numpy

When I want to execute my script I got the error: ModuleNotFoundError: No module named 'numpy'. But the module is already installed as said me the answer to the install command:
C:\WINDOWS\system32>pip install numpy
Requirement already satisfied: numpy in c:\users\simeo\anaconda3\envs\tensorflow1\lib\site-packages (1.17.2)
I'm quite new with Python, so I don't understand why it's not working and what could be the problem.
I'm using Windows 10 (64 bits). I installed Python 3.7
Thanks in advance!
For Windows try either two of these methods in cmd:
pip3 install numpy
pip3 install -U numpy
directly download latest version from sourceforge.net
If you are using pycharm, it can not install numpy from interpreter settings. After one of above method works, try installing numpy in pycharm again through interpreter settings.
You need to upgrade your Numpy library. Your current Keras version is not compatible with your Numpy module. You can use the below-given command to upgrade Numpy.pip install -U numpy
Try adding this to your code, above everything else:
import numpy

I get an ImportError: No module named 'numpy' when trying to use numpy in PyCarm, but it works fine in the interactive console

I'm already installed numpy and it works in cmd.
my Python version is 3.7.2 and numpy version is 1.16.0
When I use numpy in windows cmd, It works.
import numpy is working well in the python interactive console.
But in pyCharm, it doesn't work and errors with No module named 'numpy'.
How can I solve it?
You probably arent using the same python installation in pycharm and in your console. Did you double-check in project settings ?
If you just want to install numpy, you can create a requirements.txt file and add numpy in it, pycharm will suggest to install it if not already done.
Alternatively, you could use a venv

Python 2.7 ImportError: No module named numpy

I trying to run a program in python 2.7 that uses numpy but it gives me the error ImportError: No module named numpy. I am using Windows 10. I tried running pip install numpy and it says it was installed but I still can't run the program.
I think Pip installed your package for Python3.
That's why your python can't find Numpy
If you want to use NumPy for Python2 you must install directly 1.13.3 cp27 version, or you must install Python3.
You can check NumPy and Python versions here.
https://pypi.python.org/pypi/numpy
My personal advice is to use Python3. It's not a good time to use Python2 I think.
You can check some resources
https://wiki.python.org/moin/Python2orPython3
http://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html
https://www.activestate.com/blog/2017/01/python-3-vs-python-2-its-different-time

Python on OS X can't see most recent numpy

easy_install -U numpy
When trying to use matplotlib on Mac OS X 10.7.5, it appears that Python is always finding an older version of numpy, not the binary release I install from the SourceForge site.
When I try:
>>> from matplotlib import pyplot
I get:
RuntimeError: module compiled against API version 6 but this version of numpy is 4
(and a lot more error-tracing)
I looked for answers and tried:
sudo easy_install -U numpy
which had worked for others in my situation, despite errors when it ran. My error was:
RuntimeError: Broken toolchain: cannot link a simple C program
/tmp/easy_install-tntLIw/numpy-1.6.2/numpy/distutils/misc_util.py:252: RuntimeWarning: Parent module 'numpy.distutils' not found while handling absolute import
and I'm still unable to use matplotlib, and Python still reports seeing numpy version 1.5.1
A variety of attempts to install pre-built Python combos such as scipy, superpack all yield the same result.
I'd appreciate some help and advice.

Categories