specify location to install new package using pip - python

How can I specify a location where I can install new package
when I hit
sudo pip install virtualenv
it installs it in
/Library/Frameworks/Python.framework/Versions/2.7/bin
I wanted to the path to be in
PATH="/usr/local/bin:$PATH"

Use this,
pip install --target=d:\somewhere\other\than\the\default package_name
In your case it will be like ,
pip install --target=/usr/local/bin package_name

See here: Install a Python package into a different directory using pip?
pip install --install-option="--prefix=$PREFIX_PATH" package_name
Or, another option:
pip install package_name -t /usr/local/bin

Related

what where and how of pip when mixed with virtual environments

What i think i know currently is this:
The way to install pip is sudo apt-get install python-pip
sudo apt-get install python-pip installs pip at '/usr/lib/python3/dist-packages'
pip install abc installs abc to virtualenv where pip that gets called is
I use conda, and i have an environment 'env' created with it for some time now. I needed to install a package that said i needed pip3 > 19.0.1 so i which pip and it was 9.0.2 and it was well within the environment. i updated the pip using python -m pip install --upgrade pip and it got upgraded to 20.0.2. I am happy. However, which pip3 gives me global location, version 9.0.2 and the package i am going to be installing requires pip3 install .. command and conda install pip3 doesn't exist
questions:
How do i install pip3 in a conda environment?
Supposing i did not have conda install pip or let us say i had a non conda virtualenv created, how do i go about installing a pip in this environment so that pip install ... does not install to global location?

Pip Install keeps installing libraries to Python2.7 rather than Python3

I'm trying to install modules such as gitpython into my Python3 directory however when I run:
Pip install gitpython it automatically downloads it into python2.7
I've tried specify the Python3 directory but it says the the library has already been installed.
Requirement already satisfied: gitpython in /usr/local/lib/python2.7/dist-packages (2.1.11)
Problem is when I try to call from git import repo my Python3 can't find the module.
Is there anyway to get pip to install my libraries to Python3 as a default, can I just uninstall Python 2.7 to save problems?
I run
sudo apt install python3-pip
and it states it is already installed, so I run sudo pip3 install gitpython and it says Command 'pip3' not found, but can be installed with:
sudo apt install python3-pip
SOLUTION
sudo apt-get remove python3-pip; sudo apt-get install python3-pip
It depends of your version of pip. But I think that python3-pip may do the trick.
sudo apt-get install python3-pip
sudo pip3 install MODULE_NAME
You should use pip3 to install your packages in your python3 environment. thus instead of installing with pip use pip3 install gitpython
You can try to see the version of python with:
python --version
if the result is python 2.7, that means that your environment variable for python3 needs to be set.
After that you can try:
python -m pip install package_name
I hope it will help you =)
Adrien
You should use python3 venv Python 3 venv
python3 -m venv /path/virtual/environment
source /path/virtual/environment/bin/activate
or use pip3 to installing any libraries for python 3
$ pip3 install 'some library'
You should create virtual environment for python3. using:
virtualenv -p /usr/bin/python3 <VIRTUAL_ENV NAME>
Then activate it using:
source <VIRTUAL_ENV NAME>/bin/activate
Then install your dependency(gitpython in your case) into that.

Why packages installed with pip install --user option are not 'visible' from shell?

When I install e.g. conan.io with pip like so
sudo pip install conan
after the installation passes (and installs the packages to /usr/local/lib/python2.7/dist-packages/) I can easily trigger command from the installed package (here conan) and my shell will find it but when I install it in user model like so:
pip install --user conan
it will install it to ~/.local/lib/python2.7/site-packages/ and my shell will not find it.
What am I doing wrong here or what am I missing?
Shell scripts are installed in ~/.local/bin, you have to add the directory to your $PATH:
export PATH=$HOME/.local/bin:$PATH; conan
should work.

why pip installs to a different location than distutils install

installing with sudo python setup.py install goes to /Library/Frameworks/Python.framework/Versions/2.7/bin/git-maildiff
while if I install using pip command sudo pip install maildif
it goes to different location i.e. /Library/Python/2.7/site-packages/
why is it like that ?

How to make editable install of Python package from vcs into specific directory using pip?

By default pip installs editable packages into src subdirectory of the directory where Python is installed.
I'd like to install a package from version control to a directory of my choosing using pip's support for checking out a package from source control, for example:
pip install -e git+https://github.com/kennethreitz/requests.git#355b97165c#egg=requests-org
Is this possible?
pip help install says:
--src=DIR, --source=DIR, --source-dir=DIR, --source-directory=DIR
Check out --editable packages into DIR
For example:
pip install -e git+https://github.com/kennethreitz/requests.git#355b97165c#egg=requests-org --source-directory=/tmp
Will install the requests source in /tmp/requests-org

Categories

Resources