How to install package using pip when you have 2 Python versions - python

I have 2 anaconda in my system: one with python 2.7 & and another with python 3.5.
My command prompt is showing python version as 2.7.
I need to install one package for Python 3.5 using pip only,not conda install. I installed it using pip. It's showing installed successfully, but I'm not able to import it in Anaconda with Python 3.5.
My python 2.7 path is given in path environmental variable. Can you suggest me how to install it using pip install for python 3.5?
I don't have python 3 installed in my system. I think I have anaconda 3.5 environment in my system. Please refer the screen shot. Also I can't able to install python 3.5 in my system

To install a package in specific version, try this:
A specific version of python:
$ python-3.5 -m pip install <pkg-name>

Assuming you mean that you have two conda environments, go to a Anaconda command prompt and activate the Python 3.5 environment. Then, if pip is not installed, do:
conda install pip
Then, you should be able to run
pip install <package>
to install in to Python 3.5 provided that you are in the Python 3.5 environment.
If you don't have a Python 3.5 environment yet, simply do
conda create --name py35 python=3.5
followed by
activate py35 (Windows)
source activate py35 (Linux or macOS)

You can use:
pip install --install-option="--prefix=$PATH_PREFIX" <package_name>
or
pip install -t <direct directory> <package_name>

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)

is it any quick way to install package in PyCharm using pip when using conda environment

I am using conda as the Python3 package management tool, sometimes the conda repo did not contains some Python package. So I have to install it using pip, first I found the anaconda environment folder, the next step switch to the anaconda environment folder:
cd /usr/local/anaconda3/envs/pydolphin
then using this command to install package:
./bin/pip install musicbrainzngs
is there any short way to do this? is it possible to install it the PyCharm IDE the simple way? the PyCharm IDE using conda install by default.
First activate your conda environment:
conda activate <env>
This will switch to the version of pip installed in this environment. Then you can install using pip as per normal which will install it into your conda environment:
pip install musicbrainzngs

How to install python 3.7 on miniconda

I'm trying to install python 3.7 env for miniconda on my raspberry pi 4 model B.
But when I'm doing conda install python 3.7
I get Error: No packages found in current Linux-armv7l channels matching: 3.7.
how can I install python 3.7 in some way on that miniconda?
You can try to create new environment with this python version:
conda create -n your_env_name python=3.7
And then you need to activate it:
activate your_env_name
Here you will find more about conda environments.
miniconda only have under python3.4 for armv7l
so you need to use python3.7 for armv7l(no anaconda or miniconda just python)
You might want to try with this command : conda install -c anaconda python=3.7
Tell us if this works

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

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!

Install Python 3.6.3 in Virtualenv using pip in WIndows 10?

How do you install Python 3.6.x in a virtualenv using pip in Windows 10?
pip install python, pip install python3, pip install python3.6 don't work.
Pip and virtualenv are two separate tools. Pip is a package manager, you will use it to install packages into your virtual environment once it has been set up. Pip does not actually manage the virtual environment. Virtualenv is the tool that handles creating virtual environments.
First, you should check if you have virtualenv installed with virtualenv --version. If you do not have it, you will get an error that virtualenv is not found. You can use pip to install virtualenv with pip install virtualenv.
Once you have virtualenv, you can create a python 3.6 environment with virtualenv -p python3.6 /path/to/myvirtualenv. You will need an installation of python 3.6 for this command to work, so download and install python 3.6 first if you do not have it.
I believe that on windows if you don't have python 3.6 in your PATH variable, you may need to point directly to the python 3.6 installation instead with virtualenv -p /path/to/mypython3.6 /path/to/myvirtualenv.
See Virtualenv User Guide

Categories