why pip installs to a different location than distutils install - python

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 ?

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?

brew install python3 didn't install pip3

I installed python3 using homebrew but it didn't install pip3 or should I say it installed but it doesn't recognize the command ?
Here is what I did:
brew install python3
This installed python3 but threw an error at the end saying it couldn't link python3 and prompted me to run
brew link python3
to link the installation but this throws another error:
Linking /usr/local/Cellar/python3/3.6.3... Error: Permission denied # dir_s_mkdir - /usr/local/lib
Does anyone know how solve this ?
When I run:
brew info python3
It says:
==> Caveats
Pip, setuptools, and wheel have been installed. To update them
pip3 install --upgrade pip setuptools wheel
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.6/site-packages
See: https://docs.brew.sh/Homebrew-and-Python.html
Which makes me think pip3 is installed but not recognized. Any help is appreciated.
INFO:
OS => MacOS High Sierra 10.13.1
pip3 install twilio
-bash: pip3: command not found
Ok it took me a lot of googling but the problem is that in high sierra all permissions inside usr/local changed and homebrew has to create some folder inside usr/local. Here is how I solved everything:
I tried using sudo brew install python3 but that also threw an error
directly from Homebrew telling me that it doesn't allow the use of
sudo brew.
Create the folders I needed using sudo mkdir inside /usr/local:
sudo mkdir lib
sudo mkdir Frameworks
Change the permissions inside /usr/local so that homebrew can access them:
sudo chown -R $(whoami) $(brew --prefix)/*
Now install python3
brew install python3
This will give you a successful installation:
==> Pouring python3-3.6.3.high_sierra.bottle.tar.gz
==> /usr/local/Cellar/python3/3.6.3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python3/3.6.3/bin --in
==> /usr/local/Cellar/python3/3.6.3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python3/3.6.3/bin --in
==> /usr/local/Cellar/python3/3.6.3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python3/3.6.3/bin --in
==> Caveats
Pip, setuptools, and wheel have been installed. To update them
pip3 install --upgrade pip setuptools wheel
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.6/site-packages
See: https://docs.brew.sh/Homebrew-and-Python.html
==> Summary
🍺 /usr/local/Cellar/python3/3.6.3: 3,588 files, 56.1MB
After resolving the linking issue (e.g. https://github.com/Homebrew/homebrew-core/issues/19286 ), python3 is installed but not pip3. Reinstalling python (e.g. brew reinstall python) eventually installs pip3 as well. These steps works well for me.
GitHub user #aether2501, commenting on a sudo chown solution for a "Homebrew Permission Denied" problem, suggests instead that Homebrew be uninstalled/reinstalled after the upgrade to High Sierra.
I successfully used #aether2501's reinstall command, /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)", on High Sierra (10.13.2) without uninstalling brew first.
In addition to creating the /usr/local/Frameworks directory and setting the necessary ownership and permissions I needed to link python3, it also appears to have fixed other directory issues.
I had the same issue and used:
sudo -H pip3 install virtualenv
sudo -H pip3 install virtualenvwrapper --ignore-installed six
In my case, this fixed the issue:
brew unlink python#3.9; brew link python#3.9
(You might have to replace the version number with the version you have installed)

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.

specify location to install new package using pip

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

How can I install a python .egg file

I am trying to install twisted on python 2.6 and it seems that the Zop interface is missing.
Also it seems that it is a .egg file. I downloaded this .egg file, now how can I install it?
Install virtualenv, which includes pip. Then you can simply run:
pip install twisted
pip will handle installing the zope.interface.
Instructions for installing virtualenv and pip on OS X
This is how I installed virtualenv and pip on OS X:
curl -O http://peak.telecommunity.com/dist/ez_setup.py
sudo python ez_setup.py
sudo easy_install pip
sudo pip install virtualenv
I also like to use virtualenvwrapper with virtualenv, so I installed it using:
sudo pip install virtualenvwrapper
Instructions for installing Twisted in a virtualenv
Now to create a new virtual environment and install Twisted, I simply issue:
mkvirtualenv twisted-env
pip install twisted

Categories

Resources