Install Pillow on 3.3 when 2.7 is also installed(Linux) - python

I have both Python 2.7 and 3.3 installed on my system. I'm trying to hopefully write everything for 3.3. I've run into a snag. I need to install Pillow on 3.3 so I can use Images. How do I get it to install on 3.3. If I try
pip install Pillow
It comes up and says 'Requirement already satisfied(use --upgrade to upgrade): Pillow in /usr/lib/python2.7/dist-packages'
How do I get Pillow to install on 3.3, since that is where I need it?
I ran through the rest of the install(setuptools and prerequisites). Not sure where they installed. I did use the python3-setuptools for the initial install attempt. I don't know if that helped to control the flow of the prerequisites to 3.3 or not.
This is on a Linux system.

Your 2.7 and 3.3 have their own separate site-packages locations.
And, just as they have their own separate executables (usually python and python2.7 for 2.7, and python3 and python3.3 for 3.3), when you install pip for each one, they'll each have their own pip scripts (usually pip, pip2, and pip2.7 vs. pip3 and pip3.3).
So, just do this:
pip3.3 install Pillow
As a side note, if you use virtual environments, either via the third-party virtualenv package or the stdlib venv package (3.3+ only, and really not worth using until 3.4), this problem goes away: when you're inside a virtual environment, it's either a 2.7 environment or a 3.3 environment, and it's as if nothing else exists.
The basic design is explained in PEP 394. How pip fits into that design is explained in… as far as I know, docs that haven't been written yet, but will hopefully be part of Python 3.4.0 and/or pip 1.5.something.
Older versions of pip (I believe before 1.5.0) would use pip and pip-2.7 vs. pip and pip-3.3, which obviously leads to a bit of confusion.
And some distros have their own python-pip packages that do things differently. And then there's Arch, where python actually means 3.2. And so on.
But the basic idea is that when you have Python X.Y and V.W side by side, there will be some way to differentiate explicitly.

Related

How to manually remove pip on windows?

I am using Python 3.4 (I know it is deprecated, but don't have the power to upgrade version).
I had trouble installing some packages because of a old version of pip (1.5.6 I guess), so I went all
pip install -m pip
To upgrade version and... it broke.
Unfortunately, it installed the latest, incompatible 20.0.2 version, which now raises a RuntimeError asking me for Python 3.5, and now I'm stuck. I can't upgrade Python, I can't downgrade pip because it will not allow me to.
How can I remove or downgrade pip manually?
It is easier that it seems. You can actually use the same get-pip.py script used to install pip the first time.
The script, available here, actually contains a full working version of pip to be used to bootstrap the installation. This version is fully working, so it can be used to install packages with a different version that the one contained.
To solve, just use https://bootstrap.pypa.io/3.4/get-pip.py to recover a version of get-pip.py compatible with my python environment (note the 3.4 in the link) and run
get-pip.py pip==19.1.1
This removes the newer python version and installs the older one, restoring the usual functionalities.

Cannot uninstall 'numpy'

I've been trying to install astropy and at the end of the installation I get this message:
Cannot uninstall 'numpy'. It is a distutils installed project and thus
we cannot accurately determine which files belong to it which would
lead to only a partial uninstall.
I have tried: pip uninstall numpy and then I get the same message.
I have Python 2.7.10 in a macOS High Sierra version 13.10.5
This doesn't directly answer your question, but that's because you're asking the wrong question.
Astropy requires Python 3.5 or 3.6. Trying to get it working with Apple's pre-installed Python 2.7 is a waste of time. You might be able to get an old version working this way, but not by using the installation instructions on astropy.org, and it won't be supported even if you do.
The easy solution is to just Install the latest Anaconda 5.x with Python 3.6, because it comes with Astropy built in.
The almost-as-easy solution is to install Python 3.6 from either a python.org binary installer, or Homebrew, and then use pip3 or, better, python3 -m pip to install everything, as explained on the Astropy install page.
Either way, before doing anything else, you want to get back to a clean slate. In particular, you do not want pip, or any other scripts, attached to Apple's Python 2.7; they will only cause confusion. Assuming you can't reinstall macOS from scratch, the best way to do this is:
Look in /Library/Python/2.7/site-packages and delete everything there except for README and Extras.pth.
Look in /usr/local/bin for symlinks to anything in that site-packages. (If you don't know much about using Unix, try this command: ls -l /usr/local/bin | grep 2.7.) You'll probably have pip and pip2.7 here, and probably nothing else. But whatever you have here, delete it.
Now, when you install Python 3.6, the only thing named pip anywhere will be that Python 3.6's pip. You still want to use pip3 or python3 -m pip, but if you screw up and type pip by accident, it won't break anything.
Also, you should strongly consider using a virtual environment. See the Python Packaging Authority's User Guide (or the Anaconda docs, if you went that way) for more on this.
One simple solution I found:
sudo -H pip install astropy --ignore-installed numpy
I also had this issue and couldn't get around it in a clean way, but this is what I did:
Inside the Lib folder search "numpy" for an egg_info file (eg. numpy-1.11.0.dev0_2329eae.egg-info).
In my case, this is what Pip was looking at to determine if a current version already exists. I deleted it, then ran normal
pip install numpy
and installed the newest version.
I don't recommend this because I don't understand what it's doing under the hood and it doesn't properly uninstall the old version which could be a recipe for trouble down the line, but if you're desperate like I was then maybe this is a solution for you.

In my CentOS7.2, I have the `python3` command, but why I can not use pyvenv?

In my CentOS7.2, I have the python3 command, but why I can not use pyvenv?
[root#www myProject]# pyvenv --version
-bash: pyvenv: there is no command
[root#www myProject]# python3 --version
Python 3.5.2
[root#www myProject]# which python3
/usr/bin/python3
pyvenv was deprecated in 3.6, in favor of using python3 -m venv.
You may wonder what this has to do with your Python 3.5.2, since 3.5 < 3.6. Well, if you run a Python 3.5—or even 3.6—installer from python.org, or make install from source, you will get a pyvenv command (and possibly also pyvenv3, pyvenv3.5, and/or pyvenv-3.5). But you didn't do that; you used your distro's Python 3.5.
Distros have a long tradition of breaking up large packages like Python into a core package and various "optional" packages like python3-pip or python3-curses. And not just Red Hat;1 Debian and Ubuntu also separate venv out into a python3-venv package. How they decide what's "core" and what's "optional" is a complicated process, with a lot of legacy concerns, so I don't know exactly what the reasons are, but I can speculate.
First, most linux users seem to prefer using pipenv and/or virtualenv. They have more features, they aren't stuck with Python's glacial release cycle, and you can use the same version with Python 3.4, 3.6, and even 2.7. In 2011, adding venv seemed like TOOWTDI to eliminate the incompatible competing virtual environment solutions, but what's happened instead is that they've become compatible with each other while venv has stagnated. In fact, the official Python Packaging Authority2 recommends virtualenv for installing packages and pipenv for developing applications, and the PyPA rejected a suggestion to change that in 2017.
Also, as the 3.6 docs explain, the reason pyvenv was deprecated was basically because of the confusion it causes on Linux distros that ship multiple versions of Python.
And finally: venv depends on pip. Which isn't built in. How does that work? Well, if you get a python.org binary installer, it will include pip. And if you build it from source, Python (3.4+) uses ensurepip to bootstrap pip and setuptools. But that's primarily for the convenience of Mac and Windows users, and people who build custom versions of Python; few linux distros rely on ensurepip. After all, the reason you're using an enterprisey stable distro is that you want specific, tested versions of everything, which you do by installing their python3-pip package, not by getting a kludgy pip out of ensurepip and then doing pip install --upgrade pip to get some future version they haven't tested. So, unless a distro is going to merge their pip into their python package, it doesn't make much sense to include venv.
1. CentOS 7.2 of course just copies RHEL 7.2, because that's the point of CentOS, so the question is why RHEL 7.2 made venv an optional package.
2. Just how official is PyPA? It's not entirely clear—it's under the PSF, and uses a python.org SIG, but it maintains a separate presence. But if you look at the names involved, it's largely the same people who are both Python core devs and developers for the major linux distros. So, it's not too surprising those distros pay attention to PyPA—it's the same people making the decisions in both places.

Which version of Pip to use with my Python installs?

Being new to Python, I'd love to clear up a few points that I couldn't get from reading various articles and tutorials.
After using Homebrew to install Python3, I noticed that it had installed both Python3 and Python3.4. I was also a little surprised that there are now three versions of pip on my machine too; pip, pip3 and pip3.4.
I created a new virtualenv and told it to use Python3, using the following command:
virtualenv -p /usr/local/bin/python3 mysite
I was also surprised that the version of Python that it installed in my VM was 3.4.
Is it safe to have these multiple version of Python and Pip hanging around on my machine?
Am I right to assume that I should take extra care to use the matching version of pip with Python, for example, pip3.4 with Python3.4?
Yes, it is safe. Python uses this naming like python3.4, python3.5 etc to differentiate between releases. python3 is a symbolic link to the current python3.x version. Pip follows the same convention.
If you're using python3.4 explicitly, you should be using pip3.4 specifically as well. Otherwise, just use python3 and pip3. For Python 2, you can simply use python (which, unless you installed the Homebrew version as well), will be the system Python), and ditto for pip. python2.7 and pip2.7 may also work.
In general, to find out which Python version goes with which pip you're using, try:
pip --version
and you'll see the Python included in the result.
No need to worried about if you have multiple version of Python and Pip installed. just check your version by writing in terminal :
$ brew info python
or to check the version of pip write in terminal :
$ brew info pip
and make sure you have updated your both pip and python version (write in terminal $ brew upgrade pip/python)
and other way to install python is go to https://www.python.org/downloads/ and choose as your requirement, there is two version available 2.7.9 & 3.4.3 ,
after installing python write in terminal $ python -V to check its version :) Hope it will help :)

Python 2.6 in mac corrupted because of failled update

I'm a mac newbie and I tried to update my python version from 2.6 to 2.7. Unsuccessful, I changed my mind and uninstalled the python2.7 I had. I had a previous issue that if I typed something like:
python setup.py install
It would not install the package for python2.6, installing to the removed 2.7 version instead, to make it work I have to put
python2.6 setup.py install
And now when I try to install something with easy_install or pip (by the way, pip I have installed after 2.7 issue) I got the following huge message errors: here and here. I want to know how can I clean up my mess.
Since you were trying to install MySQLdb, how about you give ActivePython a try?
Install ActivePython 2.7 (it co-exists with Apple's System Python 2.6)
Open Terminal and type pypm install mysql-python (see PyPM Index) .. no compilation required
Make sure that /usr/local/bin/ is in front of your $PATH.
To uninstall ActivePython, you can do:
sudo /Library/Frameworks/Python.framework/Versions/2.7/Resources/Scripts/uninstall
Or, use sudo pythonselect 2.6 to switch the default Python in /usr/local/bin (if you have multiple versions of non-System Pythons installed)

Categories

Resources