If Anaconda comes with pip, why do instructions suggest installing it? - python

I have just installed Anaconda with Python3.7 on my Ubuntu 18.04. Ubuntu 18.04 comes with Python3.6 by default (but not pip).
After installing Anaconda and reading its documentation, I can see that Anaconda comes with both conda and pip. This is the case, as I can see:
$ which pip
# Output: /home/user-name/anaconda3/bin/pip
$ pip --version
# Output:
pip 10.0.1 from /home/user-name/anaconda3/lib/python3.7/site-packages/pip (python 3.7)
However, I am confused when reading the instructions from this link:
https://conda.io/docs/user-guide/tasks/manage-pkgs.html#installing-non-conda-packages
On one hand it says: " Both pip and conda are included in Anaconda and Miniconda, so you do not need to install them separately." => That's the pip I can see in my commands above.
But on the other hand it says: " It is possible to have pip installed outside a conda environment or inside a conda environment. To gain the benefits of conda integration, be sure to install pip inside the currently active conda environment, and then install packages with that instance of pip. The command conda list shows packages installed this way, with a label showing that they were installed with pip.
So I'm confused:
I clearly got a version of pip when installing Anaconda and I can see in /home/user-name/anaconda3/bin
But if I want to use pip to install a package, I need to install pip in my environment using $ conda install pip and then $ pip install package (all of this in my normal Ubuntu terminal).
I don't understand how this makes sense..
Many thanks!

Related

install pip on python 3.7 ubuntu

I am working on ubuntu, I have python 3.8 as standard installation.
However as my project have dependency on python 3.7 I have installed 3.7 and removed 3.8
now when I am trying to install pip it is installing python3.8 again and getting installed with 3.8.
I am using apt-get -y install pip to install pip.
I want to install pip on top of my python3.7 installation so that pip uses python3.7
my project have dependency on python 3.7
This is where virtual environments really useful. The idea is that you create an environment in which the required version of python and packages can live without altering the installation of python you might want to keep installed for other projects.
There are a few options, but Anaconda / miniconda are a popular way of using virtual environments and fairly easy to use. First you'll need to install miniconda:
https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html
After that from a terminal you need to create your new environment
conda create -n "py3p7" python=3.7
Then activate it:
conda activate py3p7
Then check that you've got pip installed and it's installed under the right python version:
pip --version
Which for me returns:
pip 22.2.2 from /home/MY_NAME/miniconda3/envs/py3p7/lib/python3.7/site-packages/pip (python 3.7)

Unable to install Django Version 1.11.22 with python 2.7 installed on windows 10

I have python 2.7 installed on my machine globally and the pip version is pip 20.3.4. I want to install Django version 1.11.22. When I am trying to do so with pip install Django==1.11.22, I am getting the error as mentioned in the picture. This is not just while installing Django, I am getting the same error while installing anything like pip install openpyxl.
The latest version Python 2.7.18 should work fine. Install it with pip enabled or install pip after using python -m ensurepip. Upgrade pip:
pip install --upgrade "pip<21.0" "setuptools<45"
Install virtualenv:
pip install --upgrade "virtualenv<20"
Create a virtual environment (very much recommended) somewhere and activate it:
virtualenv django-venv
django-venv\Scripts\activate.
Install Django (can be done without a virtual environment):
pip install --upgrade "Django==1.11.22".
Remember to activate the virtual environment (if you use it) every time you open a new terminal.
As the error says and #Willem Van Onsem said, python 2.7 is no longer support, you can't install it nowadays

How do I use newer pip after the upgrade? (10 --> 18)

I'm using Python 3.6 on Pycharm venv (virtual environment provided by IDE)
Terminal kept telling me to upgrade my pip from old 10.0.1 to newer 18:
You are using pip version 10.0.1, however version 18.0 is available
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
So I upgraded my pip with the suggested command.
However, when I check my pip version by pip --version, it's still on 10.0.1 and pip keeps telling me to upgrade.
pip 10.0.1 from
h:\pycharmprojects\my_project\venv\lib\site-packages\pip-10.0.1-py3.6.egg\pip
(python 3.6)
I'm sure it's already up-to-date by checking IDE's interpreter settings.
I know it doesn't really matter but it bothers me pretty much.
I already tried closing and opening new terminal but that clearly doesn't work.
How do I use my newly installed pip? Is it just Pycharm's problem?
When you are using a virtual environment in pycharm, you update the version of pip inside that virtual environment.
If you want to upgrade pip outside of the venv, type
python -m pip install pip -U
Where python is how you start python from the terminal,
which may be python3 or py -3.6 depending on your operating system.
To install inside the virtual environment, you can activate
that inside the terminal and then type the above command.
If you run this command in your PyCharm terminal, it will resolve the warning about pip:
python -m pip install -U --force-reinstall pip
Here are some comments on the JetBrains community page

PATH points to wrong version of pip

I have the anaconda distribution of python installed on my machine. Before installing anaconda, i had pip installed. Right now, my system uses the previous version of pip rather than the anaconda version. In particular
arjuns-mbp:~ Arjun$ which pip
/usr/local/bin/pip
arjuns-mbp:~ Arjun$ which easy_install
/Users/Arjun/anaconda/bin/easy_install
arjuns-mbp:~ Arjun$ which python
/Users/Arjun/anaconda/bin/python
The result is that if i call a pip install, it won't add it to my anaconda version of python. So far i haven't had an issue simply using easy_install to add packages to anaconda, but it would be nice to know what causes this discrepancy and how to fix it
EDIT
i tried using conda install pip, it doesn't work. When I do
conda list
pip showed up before and after a conda install
You probably need to conda install pip.
pip should already come with Anaconda automatically. How did you install Anaconda? No matter, though, you can just conda install pip to make sure you have a version of pip that is tied to the Anaconda distribution.
From there you can create environments as much as you like to install whatever new trial-run software tools using conda create -n env_name python pip

Installing python packages with multiple versions on OSX

I am attempting to install a package for python3.4 on Mac OSX 10.9.4. As you know, python ships with OSX, so when I installed python3.4 I was happy to find that it came with its own version of pip, that would install packages to it (installing pip on a mac with multiple versions of python will cause it to install on the system's python2.7.)
I had previously tried installing this package (https://pypi.python.org/pypi/chrome/0.0.1) with my first installation of pip (the one tied to python2.7) and found that it successfully installed on that version, but not on any others.
I ran an install with the new pip keyword for python3.4 (which when called by itself spits out the help page so i know it works) and it told me that the package was already installed and to try updating. The update revealed that I already had the most recent version. so I tried uninstalling it from just the python3.4 and reinstalling to no avail, and got the same results when uninstalling pip from python2.7 and reinstalling only on version 3.4.
I know that's a bit hard to follow but hopefully that makes sense.
I also reviewed the content here with no success.
RESOLVED:
while python did have a directory named the same as a directory it uses with packages, this was not the correct directory, for me it was in a subdirectory of library. while documentation said that referencing pip2 would cause the package to install on python3.4, this was false. however, referencing pip3.4 worked for me.
My suggestion is that you start using virtualenv.
Assuming you have 3.4 installed, then you should also have pyvenv. As for pip and 3.4, it should already be installed.
Using for example version 3.4 create your own virtual environment and activate it:
$ mkdir ~/venv
$ pyvenv-3.4 ~/venv/py34
$ source ~/venv/py34/bin/activate
$ deactive # does what is says...
$ source ~/venv/py34/bin/activate
$ pip install ... # whatever package you need
With version 2.7 first install virtualenv and then create your own virtual environment and activate it. Make sure that setuptools and pip are updated:
$ virtualenv-2.7 ~/venv/venv27
$ . ~/venv/venv27/bin/activate
$ pip install -U setuptools
$ pip install -U pip
$ pip install ... # whatever package you need

Categories