Installing numpy on Red Hat 6? - python

I'm trying to install numpy on a Red Hat (RHEL6) 64-bit linux machine that has Python 2.7. I downloaded and untar'd numpy 1.6.2 from Sourceforge, and I did the following commands in the numpy-1.6.2 folder:
python ./setup.py build
sudo python ./setup.py install #without sudo, this gives a permissions error.
Then, when I do import numpy on the Python prompt, I get ImportError: No module named numpy.
I read somewhere that numpy 1.6.2 is for Python 3.x, so I also tried the above steps with numpy 1.5.1, and I got the same ImportError.
I'm speculating that the solution lies in some environment variable gymnastics, but I'm not sure what files/directories Python needs to "see" that isn't in scope. Any suggestions for how to get numpy working?
I also tried some precompiled binaries for RHEL, but they gave various errors when I did sudo yum install [numpy precompiled binary url].rpm.
As an aside, my motivation for installing numpy is to use PyGnuplot. Also, I've installed numpy and PyGnuplot on other machines before, but it's been on Ubuntu and Mac OS.

RHEL6 ships numpy 1.4.1, see distrowatch. If 1.4.1 is new enough for you, you can install it with:
$ yum install numpy

When I install Python packages on Ubuntu using setup.py packages end up in
/usr/local/lib/python2.7/dist-packages/
assuming Python2.7
If numpy is installed there, you will need to append this path to your Python's path:
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/dist-packages/
you can append it permentanly using ~/.profile
Another way is by adding a .pth to a directory that’s already on Python’s path, for example
echo "/usr/local/lib/python2.7/dist-packages/" > /usr/local/lib/python2.7/site-packages/dist_pkg.pth
run that last command as root of course

I gave up on using RedHat, and I installed Ubuntu in a VM. It was a one-liner using apt-get.
Not an ideal solution to the question at hand, but I just didn't want to spend any more time chasing down a solution for RedHat.

Related

Different users on a machine have different versions of numpy

I have installed numpy on my debian machine using pip. Additionally, I think an older version of numpy is installed through apt-get.
Different users on my machine see the same numpy file, but have different versions of the software. For example, when I run python -c 'import os,numpy;print(numpy.__file__); print(numpy.version.version)', both users print /usr/local/lib/python2.7/dist-packages/numpy/__init__.pyc, but one of them has version 1.12.1 and the other has 1.14.
I tried to remove numpy version that is installed through apt-get, but it will remove some other software as well. So I am hoping to find a solution that avoids removing the version installed through apt-get.
Has anyone experienced a similar issue before?
you must have installed numpy manually using setup.py and apt pkg as well
you could do:
import sys
print(sys.path)
sys.path.remove('/usr/lib/python/path/2/numpy')
in your app/__init__.py
set PYTHONHOME to your preference. you could also use virtualenv to keep multiple python environments and switch between them.

ImportError: undefined symbol: _PyUnicodeUCS4_IsWhitespace

I am a python beginner and I would like some help with this. I am using Ubuntu and I had installed python using Anaconda, but then I tried to install it again using pip and now when I'm trying to run my code, at import numpy as np, I see this error
ImportError: /home/dev/.local/lib/python2.7/site-packages/numpy/core/multiarray.so: undefined symbol: _PyUnicodeUCS4_IsWhitespace
How can I fix this?
I also got this error. If you google for it, you will find lot's of similar issues. The problem can happen when you have multiple Python versions. In my case, I had the Ubuntu 16.04 Python 2.7 via /usr/bin/python and another Python 2.7 via Linuxbrew. type python gave me /u/zeyer/.linuxbrew/bin/python2, i.e. the Linuxbrew one. type pip2.7 gave me /u/zeyer/.local/bin/pip2.7, and looking into that file, it had the shebang #!/usr/bin/python, i.e. it was using the Ubuntu Python.
So, there are various solutions. You could just edit the pip2.7 file and change the shebang to #!/usr/bin/env python2.7. Or reinstall pip in some way.
In my case, I found that the Python 2.7 via Linuxbrew was incompatible to a few packages I needed (e.g. Tensorflow), so I unlinked it and use only the Ubuntu 16.04 Python 2.7 now.
Just uninstall numpy:
pip uninstall numpy
And reinstall numpy:
pip install numpy
Another thing you can do is run it on a virtual environment:
virtualenv myproject
cd myproject
source bin/activate
pip install numpy

Installing numpy for Python 2.7 while also having Python 3.4 installed?

I have both Python 2.7 and Python 3.4 (and have to have both because for the class I'm running, students have the option of using either). One student has used Python 2.7 and numpy for their project, but when I attempt to install numpy, it installs it to 3.4. I need to install it to 2.7.
I'm using numpy 1.9 from this site, which I'm told is also 2.7-specific: http://sourceforge.net/projects/numpy/files/NumPy/
However, nonetheless it still goes to the 3.4 folder. Copying it to Python 2.7 didn't work, obviously.
How do I do this?
I recommend installing with pip.
pip install numpy
If this doesn't work on windows then download the binary from http://www.lfd.uci.edu/~gohlke/pythonlibs/ and convert it to a wheel before installing.
pip install wheel
wheel convert path/to/binary
pip install numpy_wheel
Pip is recommended because you can uninstall.
To check where you are installing to
pip -V
You may have an environmental variable path to the wrong pip.
Assuming that you are using, or at least you should use pip to install the library. You can specify the python version to be installed by changing the suffix, e.g. pip-2.7 install numpy.
pip install numpy
pip-2.7 install numpy
pip-3.4 install numpy
As an alternative, in case that you do not want to use pip is to download and install the library using setup with a similar technique.
python setup.py install
python2.7 setup.py install
python3.4 setup.py install
Your PATH isn't setup correctly.
C:> where pip
Should tell you which pip it is trying to use, and it is likely whichever one it found on your PATH first...
So, instead, you will want to run it as
C:> C:\mypython2install\pip.exe install numpy
Or, setup your path correctly. See here
Just one other note on issues like this. I had a similar problem with Python 2.7 libraries not being found, because I had miniconda installed for a Python virtual environment that was hijacking calls to python from other programs. After deleting the minconda directory in my home the problem went away and python libraries that were properly installed were found again.
Note-This answer is particularly for Windows PC which has both Python2 & Pyhton3 installed on it.
Both the versions of Python has their different directories somewhat like
"C:\Python27\" ----for python2
"C:\Python35\" ---- for python3
*(or it depends on what path you chose while installing Python**)*
pip GENERALLY exist under the directory "C:\Python**\Scripts"
there you can find exe files like:
pip.exe/pip2.exe/pip2.7.exe ----for python2
pip3.exe/pip3.5.exe ----for python3
to install packages on python2:
use
Python27\Scripts\pip2.exe install package_name
(where the 1st argument is the path of exe file, it might differ for your system)
to install packages on python3:
use
Python35\Scripts\pip3.exe install package_name
there is no need to uninstall any version of python to achieve the task.

Installing OpenMDAO

I am trying to install OpenMDAO, which is an open source framework that uses python. So before I get to it, it needs 3 packages:
Fortran Compiler
NumPY
ScyPy
Which I did install using homebrew:
brew install gfortran
sudo easy_install-2.6 pip
sudo pip-2.6 install numpy
sudo pip-2.6 install scipy
Now, to install OpenMDAO, I'm supposed to be in the OpenMDAO folder and at that level I should run this script:
python go-openmdao-dev.py
But I keep getting this error:
ERROR: the following prerequisites could not be imported: ['scipy'].
So I was talking to the people at OpenMDAO, and it seems that I need to use is python2.6 - although I'm not certain, so my guess is that all the packages I installed are for python 2.7 which I downloaded since it was recommended in the python website.
The one that comes with Mac was not. So when I type in terminal the following:
python2.6
It actually runs that version. So at this point I don't know if I have to go run the script in python 2.6, but if so, I have no idea how to do it. I tried doing this and it did not work:
If anyone is familiar with the environment or just with python itself and has any suggestions, I'll really appreciate it.
This question was answered on the OpenMDAO support forum:
http://openmdao.org/forum/questions/744/error-the-following-prerequisites-could-not-be-imported-scipy
The solution was to install scipy and numpy for python2.7. The original poster first installed them for python2.6, but then ran the go-openmdao.py script with python2.7. Once all the pre-reqs were installed for 2.7, it worked.
I had the same problem after downloading scipy from a .dmg. I uninstalled, and then reinstalled from source: http://sourceforge.net/projects/scipy/files/scipy/0.12.0/ and then the openmdao installer recognized scipy.
This may be useful (from INSTALL.txt in scipy-0.12.0.tar.gz):
To test SciPy after installation (highly recommended), execute in
Python
>>> import scipy
>>> scipy.test()
To run the full test suite use
>>> scipy.test('full')
Please note that you must have version 0.10 or later of the 'nose'
test framework installed in order to run the tests. More information
about nose is available on the website__.
__ http://somethingaboutorange.com/mrl/projects/nose/

No module named numpy

I have the following programs installed
python 2.7 installed
Numpy-1.6.2-python2.7
Matplotlib-1.1.1-py2.7
I believe numpy has been installed properly because when I type import numpy in python interpreter, it doesn't give me an error. I can also check the version of the numpy installed.
I am getting the following error in my code on this line
import numpy as np
"Exceptions.ImportError:No module named numpy"
Does anyone know a solution to this problem? Thanks!
in terminal:
sudo apt-get install python-numpy
Sounds like you have another version of Python installed that PyScript is seeing. Easiest solution is to not use PyScript, but you may be able to fix it by re-installing/re-configuring PyScript to make sure that it points to the same location/version of your Python27
Chances are you have multiple versions of python installed, type:
which python
in your terminal, see what's the current one.
I've same issue on Mac.
But I solve it. I have two versions of pip.Look....
MacBook-Pro:WhiteBoxSMS4-master qinyao$ which pip
/Library/Frameworks/Python.framework/Versions/3.6/bin/pip
MacBook-Pro:WhiteBoxSMS4-master qinyao$ which pip2
/usr/local/bin/pip2
so,you need check you pip version.
Like others have mentioned you have multiple versions of python installed. Check by typing:
which python
then you can use she-bang to set your script to the version of python you can use numpy with (the one you used on your command line).
Or set your PYTHONPATH variable
I've same issue on Mac OS X.
The numpy has been installed at '/Library/Python/2.7/site-packages/numpy-override',
so import numpy works normaly.
But will fail while virtualenv actived, and with non-system preinstalled python(e.g. homebrew, or macport).
$ which python
/usr/local/bin/python
Fixed by install it again in virtualenv(which created with --no-site-packages option, or without --system-site-packages).
Pylab is part of matplotlib; so you can simply install matplotlib and you will automatically get pylab, too.

Categories

Resources