New point of view: pip dealing with multiple Python versions, Canopy, Anaconda on Linux - python-2.7

Using pip with different Python version is a common problem, as I see when I search the Internet. There are a lot of answers around, also in this forum. However nobody seems to encounter the same problem that I have:
I use Canopy python most and it was installed first. Later I installed Anaconda. Now when I try to install a program with pip it always install it in Canopy (or refuse to install it because it is already installed in Canopy.
for example:
$ pip install ipython
gives:
Requirement already satisfied...
but there are no ipython in my Anaconda-folder, it is in the /Enthought/Canopy_64bit/... folder
How can I overcome this problem?
Both versions are 2.7 and even if one is 2.7.11 and the other 2.7.12, it did not work to distinguish between the two by this.

Maybe you can try the following.
Find where both pip-s reside (whereis pip, I have it on ~/anaconda2/bin), then cd to the pip directory of the python version you want, and execute it from there.

I manage with the help of J. Corson comment:
When you want to use a particular Python installation, activate the desired environment. In my chase
source /home/per/anaconda_ete/bin/activate
then using pip made the installation in the anaconda python and I could install ipython and other stuff there... fine, thanks!

Related

scipy installation in windows 10 using pip

From the past two days, I've been trying to install scipy from the wheel file available from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy in my windows laptop 64 bit built and running Python 2.7.3. I tried running pip install scipy in the command window, it didn't work and the following error popped up in command prompt
and
I also tried typing
pip install scipy-version.whl
That didn't work too! and the same error popped up. I even updated my pip.
I read in some comments that pip doesn't work well for scipy installation. If so, what alternatives can you suggest? If not can you tell me the way to install using wheel scripts?
There are some issue while installing scipy using pip, please try using Anaconda python version which comes with all the libraries you can ever need instead of your default python.
Still if you want to use the default python refer here, as already answered here.

Python (Win 10): Installing matplotlib requires packages "freetype" and "png"?

I've been trying to install Python's matplotlib library for use with PyPlot, for use with Julia. I managed to get everything in place except for this one final library, and I feel as though I've hit a deadend trying to get it working.
When trying to install matplotlib (I've attempted using pip, regular python install, and easy_install), I get the following message at the very end of the install output, after which it is NOT installed:
* The following required packages can not be built:
* freetype, png
Confused about this, I looked around online and installed both of these (at least, what I think these were). One was the freetype project, and the other was LibPng, which was the closest thing I could find to a "png package" for windows or python in general.
This didn't initially work (for either of them), and I read somewhere that I needed a freetype.dll in my system32 folder. It was a long shot, but I went to where I installed freetype and pulled out the dll and renamed it, placing it in system32. This of course did not work (again, long shot).
Anyway, that's where I'm at. No idea where to go from here, and I'm unsure if I even grabbed the correct "packages" I should be using. Thoughts?
Use a more powerful installer
I would recommend to use Anaconda or Miniconda. In my experience with many Windows users, this is the simplest way to install packages such as matplotlib.
Anaconda
Anaconda comes with many packages for scientists. Matplotlib works out of the box. Just install as user not root.
Minoconda
If you don't want all packages of Ananconda use Miniconda
Conda
Both ways of installation (Anaconda or Miniconda) provide conda. It is an improved pip/virtualenv.
You can install matplotilb with this command:
conda install matplotlib
Enviroments:
You can create a new environment and install the packages you like:
conda create -n my_project35 python=3.5
activate my_project35
conda install matplotlib
or
conda create -n my_project27 python=2.7
activate my_project27
conda install matplotlib
Combine with pip
You can still use pip. conda "understands" what it is doing.
One snake is enough!
[This is for folks using the Linux Bash Shell on Windows 10.]
If you don't want to go the Anaconda route, you can install freetype (and png) by executing the following in the Windows 10 Bash shell:
sudo apt-get install freetype6-dev
The above command will also automatically install libpng. However, due to an error, the system will not 'realize' it has installed freetype, so you'll need to manually install pkg-config:
sudo apt-get install pkg-config
Thereafter you should be able to install matplotlib via pip without further incident.
sudo pip install matplotlib
I tired downloading matplotlib 2.2.2 with python 3.9.5, getting freetype & png errors for hours.
After downloading python 3.7.9 and removing python 3.9.5 from environment variables, installing matplotlib 2.2.2 worked with no problems!
Change your Python Version
Go to https://www.python.org/downloads/windows/, control-f search 3.7.9 and use the webinstaller. Follow all the recommended instructions
In pyvenv.cfg in your project directory switch version number to 3.7.9 and home to C:.....\Python37.
pip3 install alpaca-backtrader-api

lapack/blas-related error when trying to add scipy to miniconda-installed copy of python 2.7.10 on RedHat 6

I have two versions of python on my RedHat 6 machine: 2.7.8 that came with the system originally and 2.7.10 that I've installed using miniconda for a project. I have to use the newer version to run some demo code for another project. The demo script produced this error:
ImportError: No module named scipy.sparse
Running pip install scipy failed with a bunch of warnings and then this:
numpy.distutils.system_info.NotFoundError: no lapack/blas resources found
numpy is already installed. That is, I get Requirement already satisfied when trying to pip install numpy.
The yum install command recommended on the SciPy install page completed fine but did not help, probably because this python version is installed at a non-default location.
Same result after building blas and lapack from source as described here
How do I get scipy to install properly?
Thx
I think you don't have lapack/blas library.
try this.
yum install python-devel python-nose python-setuptools gcc gcc-gfortran gcc-c++ blas-devel lapack-devel atlas-devel
it will install all what you need.
If you use Anaconda/miniconda, then use the conda package manager, not pip:
conda install scipy.
Value of a Peace of mind once starting always from a [Defined state]
There are many issues with pip / yum installer strategies that we, mortals, can spend ages on our attempts to get resolved.
Since I started to use the Travis Oliphant's Anaconda fully-fledged package-manager, these dependency-related / version-colliding issues simply disappeared. Well did not disappear, but principally do not appear.
Why?
Anaconda package-manager both allows one to keep separate versions ready / reconfigurable via Anaconda for individual python launches
and
Anaconda resolves updates in a smart way, one would never experience with manual/semi-manual pip/yum installers
In other words, if you strive to get rid of issues, opt to install Anaconda and start using it's (parallel) multi-versions installation / setup controls and it's smart package-manager facilities.
n.b.: this is not a commercial/spam/PR, this is just personal experience after many years of troubles with individual package updates' collisions / compatibility back-testing troubles in multi-py 2.5 / 2.6 / 2.7 installations environments

too many pythons on linux

i recently started using python with xubuntu on virtualbox but i'm having problems. I want to be able to use numpy so i thought that apt-get install python-numpy would solve everything, but using the shell i kept getting No module named numpy. I used IDLE and it could find it. I also have IDLE (using Python-2.7), and again it could import numpy. Then i noticed that the shell had python 2.7.9, while the IDLEs had python 2.7.6.
Using
import sys
print sys.path
this if what i get from 2.7.9 (shell)
/usr/local/lib/python2.7/site-packages/setuptools-17.0-py2.7.egg
/usr/local/lib/python2.7/site-packages/Pillow-2.3.0-py2.7-linux-x86_64.egg
/usr/local/lib/python2.7/site-packages/mock-1.0.1-py2.7.egg
/usr/local/lib/python27.zip
/usr/local/lib/python2.7
/usr/local/lib/python2.7/plat-linux2
/usr/local/lib/python2.7/lib-tk
/usr/local/lib/python2.7/lib-old
/usr/local/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/site-packages
and from 2.7.6 (IDLE)
/home/alessandro
/usr/bin
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/PILcompat
/usr/lib/python2.7/dist-packages/gtk-2.0
/usr/lib/pymodules/python2.7
/usr/lib/python2.7/dist-packages/ubuntu-sso-client
I understand that i have two versions of python installed and somehow i ended up installing packageg into only one of them (the 2.7.6).
I'd like to be able to use 2.7.9 both in the shell and in IDLE and also i'd like to install so that python 2.7.9 can see them.
I read that i can add paths to the python sys.path, but isn't there a more efficient/persistent way to do what i want?
PS: tell me if you need more informations
For my projects I usually create a virtualenv for each python version I need for the project at hand. I manage them using pip to install specific versions that I need. Moreover you should be able to choose the python path in your IDE. While I'm not using IDLE, I read here that apparently idle comes along with the python versions during install. So maybe your idle versions collide with each other. If you want to have only one python version at the time on your machine you might consider a simple remove and fresh install of your desired version. Again I would recommend pip over apt-get etc. Hope this is of help for you.
Worth to check PyDev, a plugin for Eclipse to work on python.
http://marketplace.eclipse.org/content/pydev-python-ide-eclipse , or http://pydev.org/.
This allows you to configure the python version for different project's.
I have some project's with python 2.7 and others with 3.4.
it's checks the whole system in search for the PYTHONPATH to use!

How to use -pip- to install packages that can work with Anaconda?

I am trying to install some additional packages that do not come with Anaconda. All of these packages can be installed using pip install PackageName. However, when I type this command at the Anaconda Command Prompt, I get the following error:
Fatal error in launcher: Unable to create process using '"C:\Python27\python.exe
" "C:\python27\scripts\pip.exe" install MechanicalSoup'
I also tried to run the command from the python interpreter after import pip but that also did not work (I got a SyntaxError: invalid syntax).
I am a noob and understand that this might be a very basic question so thanks for your help in advance!
PS: I am using Windows 7, 64 bit, conda version: 3.7.1 and python version: 2.7.6.
When installing anaconda, you are asked if you want to include the installed python to your system PATH variable. Make sure you have it in your PATH. If everything is set up correct, you can run pip from your regular command prompt aswell.
Using #heinzchr's and #mmann's suggestions I was able to piece together the problem. I already had a version of Python 2.7 saved at C:\Python27 and I had to remove this from the Path (My Computer's properties> Advanced system settings> System variables> Path). I can now use pip install from the command line.
There is a way around the use of pip
From the anaconda terminal window you can run:
conda install PackageName
Because MechanicalSoup isn't in one of anaconda's package channels you will have to do a bit of editing
See instructions near the bottom on their blog
For those looking for Python packages not added to current channels in anaconda, try https://conda-forge.org/ For example, if you want to install MechanicalSoup you'll find it at https://anaconda.org/conda-forge/mechanicalsoup and use the -c option to tell conda the channel to use:
conda install -c conda-forge mechanicalsoup