Installing f2py in ubuntu - python

I wonder if anyone could help me with one issue: I am using ubuntu 12.04 and I wanted to install f2py. However the version found here:
https://sysbio.ioc.ee/projects/f2py2e/index.html#installation
Gives me an error with python 2.7.6. This issue arises to many users due to word "as" becoming a keyword since python 2.6 (http://comments.gmane.org/gmane.comp.python.f2py.user/1802)
Hence which is the updated way to install f2py? Or using the one from numpy?
Thanks
Vital

The version you link to is very very old. The installation instructions refer to Python2.1!
You'll find a newer version by searching PyPi. But the homepage for that package states that, as of 2007-07-19,
F2PY is now part of NumPy. All the development and maintenance of F2PY is carried out under NumPy SVN tree.
So the easiest way to install f2py on ubuntu is
to install numpy:
sudo apt-get install python-numpy

Related

Problems installing the right version of Python

Has anyone had this problem: when trying to install python>=3.6.6 by typing sudo apt-get install python>=3.6.6, to get another version? I get 3.5.3 and I do not understand why it happens so.
Could anyone help?
Thanks!
The version of python installed through apt is determined by the configuration in /etc/apt/sources.list. You can modified it to add additional sources but it is not recommended to do so since it may cause unexpected problems. A more safe way is to use anaconda or miniconda to manage your python environment. You can install any version of python through conda. Refer to this tutorial.

Python Modules simply won't install

Okay. So I have been trying a lot lately to install python modules. They won't install. Yes, I have set the path. And yes, I tried almost everything already on this website. I have Python 3.6.0 and Windows 10.
For instance, this is what it says when I ask the cmd to install numpy.
It basically says Atlas not supported, atlas not found. LAPACK not supported or found. And probably a thousand other things. Its really frustrating. If someone could help please.
Look this
And this
It seems that your are trying to install numpy or a numpy dependency from source. So the installer tries to compile from C source code. This is not an easy task under Windows, since you need to install the whole tool chain.
You need to install the wheel package that matches both your platform/OS but also your Python version.
According to the official PyPi, there is no binary distribution for Python 3.6 (except for Mac OS X).
The solution is to downgrade to Python 3.5.
Note: consider using a recent version of pip to install packages.

Numpy installing via PyPI vs distro package manager

This is probably a trivial question and maybe even a duplicate.
What is the difference between numpy/scipy as installed from PyPI and as opposed to the one installed from a distribution's repository, say Ubuntu using apt-get? I think I have a vague idea- numpy as installed from PyPI requires a lot of other tools like gcc, gfortran before it can build. I am guessing a distro's version of numpy package comes with all these tools? Not sure if this is the right picture.
If so, using PyPI depending on which python I am pointing to I can install numpy and scipy for a particular version of python. Using apt-get, can you install numpy and scipy for a specific version of python? Does the package manager apt-get use the version of python I am pointing to?
The main difference is that, in pip you have a always a fresh version, in
ubuntu repository you always have a little outdated python package.
And yes you can install for example python-numpy or python3-numpy and that will download all dependency -> http://packages.ubuntu.com/precise/python-numpy.
the same is with PyPI, you can use pip/pip3 to install package that you want, but that can be more 'tricky', because sometimes you must find a dependency manually. Like with ipython-notebook, when you install from apt-get, everything will be downloaded and you don't care about dependency, but when you want a fresh version and you download this from pip, you must also install tornado,jsonscheme, pyzqt manually with using pip.
And with using pip/apt-get you can install numpy/scikit for different python version. (in ubuntu default version of python is 2.7 so when you install sth for python3 you must add 3 ;) )
apt-get install python-numpy /pip install numpy
or
apt-get install python3-numpy/ pip3 install numpy
and the same with scikit :)
The majority of Linux distributions have a package manager that installs pre-compiled binary packages. In the case of numpy/scipy they would thus install Python source code with the precompiled C/Fortran extensions. No C/Fortran compilers are necessary for the install.
PyPI on the other hand, is a package manager for Python that is very roughly a wrapper around the python setup.py install command. It will in particular compile the necessary C/Fortran extensions from sources. It thus requires the gcc, gfortran compilers to be present on the system. This takes longer (~15 min for numpy) but has the advantage that it could be potentially optimized with compilation flags to the current CPU architecture and therefore marginally faster (that shouldn't matter much in practice though).

Why did matrix multiplication using python's numpy become so slow after upgrading ubuntu from 12.04 to 14.04?

I used to have Ubuntu 12.04 and recently did a fresh installation of Ubuntu 14.04. The stuff I'm working on involves multiplications of big matrices (~2000 X 2000), for which I'm using numpy. The problem I'm having is that now the calculations are taking 10-15 times longer.
Going from Ubuntu 12.04 to 14.04 implied going from Python 2.7.3 to 2.7.6 and from numpy 1.6.1 to 1.8.1. However, I think that the issue might have to do with the linear algebra libraries that numpy is linked to. Instead of libblas.so.3gf and liblapack.so.3gf, I can only find libblas.so.3 and liblapack.so.3.
I also installed libopenblas and libatlas:
$ sudo apt-get install libopenblas-base libatlas3-base
and tried them, but the slowdown doesn't change. So, my questions are:
What's the difference between the packages with and without the "gf"?
Is this possibly causing the slowdown in the matrix multiplications?
If so, how can I go back to libblas.so.3gf and liblapack.so.3gf? They seem to be discontinued in Ubuntu 14.04.
Thanks much!
wim is correct, in that the problem is probably caused by numpy linking to a slower BLAS library (e.g. the reference CBLAS library rather than ATLAS).
You can check which BLAS library is being linked at runtime by calling the ldd utility on one of numpy's compiled shared libraries.
For example, if you installed numpy in the standard location using apt-get:
~$ ldd /usr/lib/python2.7/dist-packages/numpy/core/_dotblas.so
...
libblas.so.3 => /usr/lib/libblas.so.3 (0x00007f01f0188000)
...
This output tells me that numpy is linked against /usr/lib/libblas.so.3. This is usually a symlink to the reference CBLAS library, which is pretty slow.
You could, as wim suggests, remove the version of numpy installed via apt-get and build it yourself, either using pip or by downloading the source directly. However, I would strongly discourage you from using sudo pip install ... to install Python modules system-wide. This is a bad habit to get into, since you run the risk of breaking dependencies in your system-wide Python environment.
It is much safer to either install into your ~/.local/ directory using pip install --user ... or even better, to install into a completely self-contained virtualenv.
Another option would be to use update-alternatives to force your system-wide numpy to link against a different BLAS library. I've written a previous answer here that shows how to do this.
Are you installing numpy through package manager?
If so, I recommend to go through pip instead so you can clearly see in the build process what is being successfully linked during setup.
Remove the apt version (sudo apt-get purge python-numpy)
Install build-deps headers and static libraries (sudo apt-get install libblas-dev liblapack-dev gfortran), maybe there are some others but these are the ones I remember.
pip install numpy

OSX - "NumPy/SciPy requires Python 2.6 to Install"

I just got a new machine (osx-lion), and I'm in the process of trying to reinstall all of my tools. I'm trying to install NumPy and SciPy. I know that the version Apple ships isn't exactly what makes NumPy and SciPy happy, so I went to Python.org and installed the recommended version (2.7.3), which went smoothly. Now when I which python, it points to the new 2.7 version which was different than the one the machine came with. My PATH variable also contains the path to the 2.7 (python.org) version.
Then I downloaded NumPy and got the message:
numpy 1.6.1 cannot be installed on this disk. numpy requires python.org Python 2.6 to install.
So then I tried SciPy, and got the same message:
scipy 0.10.1 can't be installed on this disk. scipy requires python.org Python 2.6 to install.
After some googling, I see that the 2.6 required is just 2.6 or or greater, and I did install the Python.org version (2.7), but I must be missing something.
Edit - Just tried rebooting the machine in case there were some changes that needed a restart to take effect, but that didn't help.
Any help would be greatly appreciated. Thanks all.
A simple and easy way to install numpy and scipy without going through version conflicts is to use the Enthought python distribution. They have a free version that includes python and the two packages you want, and the iPython console that I like a lot. They also offer a more extensive distribution that is free only for academic use, otherwise you have to pay for it.
python.org recommends installing an updated version of python 2.x instead of the version that comes with OSX. Following this advice, I was able to get scipy and numpy to work without enthought. Here are the versions that I am using (some version numbers missing, my notes are not complete):
Python 2.7.2 from python.org (64 bit)
numpy/scipy (OSX 10.6 build)
ipython 0.12
readline
matplotlib
At the end of the day, enthought.com is the easiest way to install everything.
Install latest version of Xcode/devtools and fortran ( http://www.scipy.org/Installing_SciPy/Mac_OS_X ).
Confirm python version
python --version
Install pip
sudo easy_install pip
Install numpy
sudo pip install numpy
If it complains you have an older version of bumpy installed, upgrade it.
pip install numpy --upgrade
check how many tests it fails ;)
sudo pip install nose
python
import numpy as np
np.test('full')
If you have the OSX developer tools installed, you should be able to install from source without much trouble.
make sure you have setuptools/distribute installed in your Python.org installation: run distribute_setup.py from the new python
make sure you have the gfortran compiler for scipy. This is just brew install gfortran if you use Homebrew.
use the right easy_install to just do easy_install numpy; easy_install scipy. (Or, easy_install pip and then pip install numpy; pip install scipy.)
im not exactly sure how osx works, but if it prompts you for a directory select the one in which you installed python 2.7
you could also download numpy for 2.6 here: (via sourceforge)
http://sourceforge.net/projects/numpy/files/NumPy/1.6.1/numpy-1.6.1-py2.6-python.org-macosx10.3.dmg/download
note: i was searching for a scipy for 2.6 when i came across this on their website:
"Note that the Mac OS X binaries work with the Python from python.org, not with the Python provided by Apple. "
I suggest using the superpack by https://twitter.com/fonnesbeck you can find the install script here http://fonnesbeck.github.io/ScipySuperpack/
Enthought's canopy is a lot of money for software they did not build themselves.

Categories