Install Numpy 1.9.2 on Ubuntu from Terminal - python

I have Python 2.7 version and I am trying to upgrade or fresh install numpy 1.9.2 version. I am trying the upgrade option.
command:
pip install numpy --upgrade
message:
Requirement already up-to-date: numpy in /usr/local/lib/python2.7/dist-packages
Cleaning up...
But still it has same old 1.8 version
Any other alternative to upgrade the numpy version ?

If the pip is not working simply install numpy manually. First clone the git repo
git clone git://github.com/numpy/numpy.git numpy
Then enter its directory and just install the lib
cd numpy
sudo python setup.py
#edit numpy happens to require cython. It can be installed either via pip
pip install cython
or downloaded from here http://cython.org/#download and setup manually like above
sudo python setup.py

Related

"ERROR: Failed building wheel for numpy" during pip install opencv-python on python 3.10 [duplicate]

Python 3.10 is released and when I try to install NumPy it gives me this: NumPy 1.21.2 may not yet support Python 3.10.. what should I do?
If on Windows, numpy has not yet released a precompiled wheel for Python 3.10. However you can try the unofficial wheels available at https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy .
Specifically look for
numpy‑1.21.2+mkl‑cp310‑cp310‑win_amd64.whl or
numpy‑1.21.2+mkl‑cp310‑cp310‑win32.whl
depending on you system architecture.
After downloading the file go to the download directory and run pip install "<filename>.whl".)
(I have personally installed numpy‑1.21.2+mkl‑cp310‑cp310‑win_amd64.whl and it worked for me.)
Since you are on MS-Windows you can also make use of pipwin - this windows only utility is pip installable and can download and install a number of "unofficial" builds (provided by the excellent Christoph Gohlke) of scientific from the https://www.lfd.uci.edu/~gohlke/pythonlibs/ but takes the guesswork out of which file(s) to download and install.
A session might run:
pip install pipwin
pipwin install numpy
Alternatively you could use the py launcher as in:
py -3.10 -mpip install pipwin
py -3.10 -mpipwin refresh
py -3.10 -mpipwin install numpy
The middle step tells pipwin to populate its list of what is currently available.
If you don't mind using Docker and Debian, the official python:3.10 (==python:3.10-bullseye) docker container has pip pre-installed. And some packages like numpy can be installed using pip install and run under python 3.10 (good luck with other packages though:).
Here's some PoC and proof that numpy really works there:
$ docker run -it --rm --name python310 -u 0 python:3.10 bash -c 'pip --version; pip install numpy --user --no-cache; pip show numpy; python -c "import numpy as np; print(np.ones(5))"'
..which should output:
pip 21.2.4 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)
Collecting numpy
Downloading numpy-1.21.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.9 MB)
|████████████████████████████████| 15.9 MB 36.9 MB/s
Installing collected packages: numpy
WARNING: The scripts f2py, f2py3 and f2py3.10 are installed in '/root/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.21.4
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
Name: numpy
Version: 1.21.4
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:
License: BSD
Location: /root/.local/lib/python3.10/site-packages
Requires:
Required-by:
[1. 1. 1. 1. 1.]
I use Ubuntu and I had the same issue but when changed the version from 1.19.5 to 1.22.1 my issue fixed

uninstalling pip3 on mac

I am trying to get the installation right with python 3, pip and pip3. I am working on a mac and by default. I have Python 2.7.10
python -V
Python 2.7.10
python3 -V
Python 3.5.1
What is the correct order of installation commands to install python3 pip and pip3 so that both pip and pip3 can be linked to python3?
This what I get when I try to see what versions I already have:
$ pip -V
-bash: /usr/local/bin/pip: No such file or directory
$ pip3 -V
pip 7.1.2 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (python 3.5)
I need to get this right so that I can install numpy afterward because now with what I have above this is what I get:
$ pip3 install numpy
Collecting numpy
Could not find a version that satisfies the requirement numpy (from versions: )
No matching distribution found for numpy
I have Solved it. as #keithpjolley suggested. I installed anaconda, launched it, and I used the command:
conda install numpy
I let it solve the environment. It gave me an older version of numpy at first so I upgraded:
conda install numpy=1.13
Now everything is working with my code.

Pip install Numpy Errors

I tried to upgrade pandas from 19.2 to 20.2
I did pip -install --upgrade pandas
and it ran successfully. However, now when I try to import pandas I get:
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
I uninstall and re-install numpy with pip uninstall numpy and pip install numpy. But it seems like numpy is using a cashed version. I did install numpy MKL a while back....:
C:\Windows\System32>pip install numpy
Collecting numpy
Using cached numpy-1.13.0-cp36-none-win32.whl
Installing collected packages: numpy
Successfully installed numpy-1.13.0
How do i install the "normal" version of numpy? As I believe this cached version is causing the issues
Go to this link and download the relevant numpy .whl file:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Then navigate to the directory from which it is downloaded to and run the pip install command for that file.
Hope this helps!
Do you use anaconda ? Try to run this script in cmd :
"conda install numpy"
Another solution might be to delete .pyc file your python project created. Python interpreter compiles source to byte code, which is stored in .pyc and byte code is afterwars executed by Pythons virtual machine.

How to install numpy to Python 3.5?

I'm attempting to install numpy on python3.5 via :
python3.5 -m pip install numpy
but receive error :
/usr/local/bin/python3.5: No module named pip
Same error for pip3 :
python3.5 -m pip3 install numpy
/usr/local/bin/python3.5: No module named pip3
Reason I'm attempting to install numpy this way is pip3 is pointing to a 3.4 dist-packages dir :
pip3 install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/local/lib/python3.4/dist-packages
Cleaning up..
How to install numpy to Python 3.5 ?
Update:
I decided to use docker in order to install on a clean ubuntu14.04 environment and it worked out of box.
Although using virtual environment is advisable in many use-cases, it is not strictly required. You can have a system python3.5 and a pip installation associated with it.
Note that Python 3.5 is now end-of-life and pip has now dropped support. The final version of pip supporting Python 3.5 was 20.3.4 (Jan 2021).
Download this file: pip-20.3.4-py2.py3-none-any.whl
Bootstrap a pip installation using the wheel file: sudo python3.5 pip-20.3.4-py2.py3-none-any.whl/pip install pip-20.3.4-py2.py3-none-any.whl
Install numpy with python3.5 -m pip install --user numpy
I strongly recommend using a virtual environment and in the case of the scientific Python stack, I further recommend using anaconda. It will save you loads of headaches in the future.
Download anaconda for Python3.5.
Create an environment.
Activate it.
conda install numpy.
Step 2 looks like this:
conda create --name env_name numpy
Step 3 looks like this:
source activate env_name
Step 4 looks like this:
conda install numpy
Now, anytime you want to use numpy or any other dependency in your environment, you just do source activate env_name.
To deactivate, do:
source deactivate

Install numpy in Python virtualenv

I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have the error when installing numpy in the virtualenv.
Maybe, you have any ideas to fix?
The problem is SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
so do the following in order to obtain 'Python.h'
make sure apt-get and gcc are up to date
sudo apt-get update
sudo apt-get upgrade gcc
then install the python2.7-dev
sudo apt-get install python2.7-dev
and I see that you have most probably already done the above things.
pip will eventually spit out another error for not being able to write into /user/bin/blahBlah/dist-packages/ or something like that because it couldn't figure out that it was supposed to install your desiredPackage (e.g. numpy) within the active env (the env created by virtualenv which you might have even changed directory to while doing all this)
so do this:
pip -E /some/path/env install desiredPackage
that should get the job done... hopefully :)
---Edit---
From PIP Version 1.1 onward, the command pip -E doesn't work. The following is an excerpt from the release notes of version 1.1 (https://pip.pypa.io/en/latest/news.html)
Removed -E/--environment option and PIP_RESPECT_VIRTUALENV; both use a restart-in-venv mechanism that's broken, and neither one is useful since every virtualenv now has pip inside it. Replace pip -E path/to/venv install Foo with virtualenv path/to/venv && path/to/venv/pip install Foo
If you're on Python3 you'll need to do sudo apt-get install python3-dev. Took me a little while to figure it out.
If you're hitting this issue even though you've installed all OS dependencies (python-devel, fortran compiler, etc), the issue might be instead related to the following bug:
"numpy installation thru install_requires directive issue..."
Work around is to manually install numpy in your (virtual) environment before running setup.py to install whatever you want to install that depends on numpy.
eg, pip install numpy then python ./setup.py install
This answer is for those of us that compiled python from source or installed it to a non standard directory. In my case, python2.7 was installed to /usr/local and the include files were installed to /usr/local/include/python2.7
C_INCLUDE_PATH=/usr/local/include/python2.7:$C_INCLUDE_PATH pip install numpy
I recently had the same problem. I run Debian Jessie and tried to install numpy from a Python 2.7.9 virtualenv. I got the same error -- numpy complaining that Python.h is missing while python2.7-dev and gcc are already installed.
File "numpy/core/setup.py", line 42, in check_types
],
File "numpy/core/setup.py", line 293, in check_types
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
I'm running pip 1.5.6 and it doesn't appear to have command line option '-E'
$ pip -V
pip 1.5.6 from /home/alex/.virtualenvs/myenv/local/lib/python2.7/site- packages (python 2.7)
Upgrading pip to the latest verson 7.0.3 solves the problem
$ pip install --upgrade pip
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-7.0.3-py2.py3-none-any.whl#md5=6950e1d775fea7ea50af690f72589dbd
Downloading pip-7.0.3-py2.py3-none-any.whl (1.1MB): 1.1MB downloaded
Installing collected packages: pip
Found existing installation: pip 1.5.6
Uninstalling pip:
Successfully uninstalled pip
Successfully installed pip
Cleaning up...
Now it is possible to install numpy
$ pip install numpy
Collecting numpy
Downloading numpy-1.9.2.tar.gz (4.0MB)
100% |████████████████████████████████| 4.0MB 61kB/s
Installing collected packages: numpy
Running setup.py install for numpy
Successfully installed numpy-1.9.2
This is probably because you do not have the python-dev package installed. You can install it like this:
sudo apt-get install python-dev
You can also install it via the Software Center:
#samkhan13 solution didn't work for me as pip said it doesn't have the -E option.
I was still getting the same error, but what worked for me was to install matplotlib, which installed numpy.

Categories

Resources