I am trying to install flake8 package using pip3 and it seems that it refuses to install because is already installed in one local location.
How can I force it to install globally (system level)?
pip3 install flake8
Requirement already satisfied (use --upgrade to upgrade): flake8 in ./.local/lib/python3.4/site-packages
Please note that I would prefer a generic solution (that should work on Debian, OS X maybe even Windows), one that should be used on any platform so I don't want to specify the destination myself.
For some weird reason it behaves like I already specified --user which in my case I didn't.
The only way I was able to install a package globally was to first remove it and install it again after this. Somehow it seems that pip (8.1.1) refuses to install a package globally if it exists locally.
Disclaimer: No virtual environments were used or harmed during the experiments.
Why don't you try sudo with the H flag? This should do the trick.
sudo -H pip install flake8
A regular sudo pip install flake8 will try to use your own home directory. The -H instructs it to use the system's home directory. More info at https://stackoverflow.com/a/43623102/
Maybe --force-reinstall would work, otherwise --ignore-installed should do the trick.
Where does pip installations happen in python?
I will give a windows solution which I was facing and took a while to solve.
First of all, in windows (I will be taking Windows as the OS here), if you do pip install <package_name>, it will be by default installed globally (if you have not activated a virtual enviroment).
Once you activate a virtual enviroment and you are inside it, all pip installations will be inside that virtual enviroment.
pip is installing the said packages but not I cannot use them?
For this pip might be giving you a warning that the pip executables like pip3.exe, pip.exe are not on your path variable.
For this you might add this path ( usually - C:\Users\<your_username>\AppData\Roaming\Programs\Python\ ) to your enviromental variables.
After this restart your cmd, and now try to use your installed python package. It should work now.
For windows 10:
Installing Python for all users is straight forward since when you install you have to click a checkbox for all users.
In order to install modules globally under C:\Program Files\Python310\Lib\site-packages
start CMD prompt as administrator and then install modules
python -m pip install selenium
For the Windows case:
Are you using virtualenv? If yes, deactivate the virtualenv. If you are not using a venv, the package should have already be installed on system level (system-wide). In that case, try to upgrade the package.
pip install flake8 --upgrade
I actually don‘t see your issue. Globally is any package which is in your python3 path‘s site package folder.
If you want to use it just locally then you must configure a virtualenv and reinstall the packages with an activated virtual environment.
Related
I'm looking for a way to make a virtualenv which will contain just some libraries (which I chose) of the base python installation.
To be more concrete, I'm trying to import my matplotlib to virtualenv during the creation of virtualenv. It can't be installed efficiently with pip or easy_install since it misses some fortran compiler libs. The way I did it until now was to manually copy from:
/usr/lib/python2.7/dist-packages/ to virtualenv_name/lib/python2.7/dist-packages/
However this prevents the manully imported links to be registerd by yolk (which prints all currently available libs in virtualenv).
So, is there a way to do a selective variant of the
virtualenv --system-site-packages
Create the environment with virtualenv --system-site-packages . Then, activate the virtualenv and when you want things installed in the virtualenv rather than the system python, use pip install --ignore-installed or pip install -I . That way pip will install what you've requested locally even though a system-wide version exists. Your python interpreter will look first in the virtualenv's package directory, so those packages should shadow the global ones.
You can use the --system-site-packages and then "overinstall" the specific stuff for your virtualenv. That way, everything you install into your virtualenv will be taken from there, otherwise it will be taken from your system.
I am late to the game using python.3.8 and pip3 on Ubuntu 20.04.
The ONLY way to get rid of the annoying .local install for me was to set an environment variable (bash):
export PYTHONNOUSERSITE="true"
This does not need to be "true" anything will work. I would not go for a 0. ;-)
Install virtual env with
virtualenv --system-site-packages
and use pip install -U to install matplotlib
I have a new Macbook - a user installed it, and then I installed a new user (mine), granted admin privileges and deleted the old one. I am on OS Catalina.
Since the installation I've been having several permission problems.
VSCode can't find Jupyter Notebook, pip installs packages at ~/Library/Python/3.7/site-packages.
When I do which python3 I get usr/bin/python3.
When I do pip3 install <package> I get: Defaulting to user installation because normal site-packages is not writeable And then it says it has already been installed, even though I can't access it when I do import <package>.
It's seems clear that this is a permission problem, pip can't install to the "base" python, and them python can't find what I've installed into ~/Library/Python/3.7/site-packages.
I've tried reinstalling the OS, but since I haven't done a clean install, it didn't change anything.
What am I missing?
How exactly can I fix permissions? Where do I want packages to be installed (venv sure, but some packages I want global (like jupyter).
As #TomdeGeus mentioned in the comments, this command works for me:
Python 3:
python3 -m pip install [package_name]
Python 2:
python -m pip install [package_name]
It's best to not use the system-provided Python directly. Leave that one alone since the OS can change it in undesired ways, as you experienced.
The best practice is to configure your own Python version(s) and manage them on a per-project basis using virtualenv (for Python 2) or venv, possibly via poetry, (for Python 3). This eliminates all dependency on the system-provided Python version, and also isolates each project from other projects on the machine.
Each project can have a different Python point version if needed, and gets its own site_packages directory so pip-installed libraries can also have different versions by project. This approach is a major problem-avoider.
python3.7 -m pip install [package_name]
(you should use the version that you have, of course)
solved it for me.
The most voted answer python3 -m pip install [package_name] does not help me here.
In my case, this was caused by a conflict with the dominating 3.6 version that was also installed as a default. You might ask yourself why you have 3.6 on your system, you will most probably not use that version now. The reason is that 3.6 is used as an independent default python version for many package installers. Those installers do not want to check which individual version you use and whether that fits, they just use 3.6 as a default, if you like it or not.
Here is a proof by example --upgrade pip:
pip3 install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in
/home/USERNAME/.local/lib/python3.6/site-packages (20.3.1)
python3 -m pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in
/home/USERNAME/.local/lib/python3.6/site-packages (20.3.1)
python3.7 -m pip install --upgrade pip
Collecting pip
Cache entry deserialization failed, entry ignored
Using cached https://files.pythonhosted.org/packages/ab/11/2dc62c5263d9eb322f2f028f7b56cd9d096bb8988fcf82d65fa2e4057afe/pip-20.3.1-py2.py3-none-any.whl
Installing collected packages: pip Successfully installed pip-20.3.1
I'm using Anaconda on Ubuntu and had the same problem.I fixed it by the following steps:
deactivating current environment
conda deactivate
Then, the base environment activates. I deactivated the base conda environment too. To do so, I used conda deactivate again.
Finally, I activate my project environment directly (instead of activating from the base environment) by the following command. Afterward, I installed the intended package successfully and worked perfectly.
conda activate myenv
pip install somepackage
sudo pip install
Worked for me. But pip install is not recommended to be run with sudo. The issue I was facing on BIGSUR was, it was using system python. Once I Installed python 3.9 using
brew install python#3.9
Then pip worked fine
For readers who thought themselves accidentally update system pip:
If you saw this info in your terminal output:
Defaulting to user installation because normal site-packages is not writeable
then you will be fine. Use the pip3 you just updated to run:
pyenv global system # since I use pyenv
pip3 uninstall pip # this one does the trick
Then you can check again pip3 --version will point to the original old (XCode/System-)pip. E.g. (2022/2/28):
pip 20.2.3 from /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)
It occurs with me when I the virtual enviroment folder name was : venv.
in this case, It gives errors like :
No module pip
Default folder is unwritable
renaming the folder solve the proplem.
Check on the command line "which python" to see if it is the value you expect.
If you have a virtual environment activated, check /venv/bin/activate to see the value of VIRTUAL_ENV= and make sure it is the correct path . The path may be wrong if you renamed or moved the project. If the path is wrong, you can delete the venv and make a new one.
For me, none of the suggestions worked so I had to delete the current virtual environment folder venv and recreate it using one of the following commands:
python -m venv venv
python3 -m venv venv
Check the source of pip on Ubuntu 20.04
which pip
returns the correct path
/home/myname/fullstack/person_api/venv/bin/pip
UPDATE
I presume that some might encounter this problem because they set python path as environmental variable like this in ~/.bashrc:
python=/path/to/python
which you should not be doing! Instead we could do:
py=python
PATH=/path/to/python:$PATH
I bumped into this issue specifically because of this!
Had this same issue on a fresh install of Debian 9.12.
Rebooting my server solved the issue.
In my case on Linux, the ownership of the conda env directory had changed to another Linux user (long story), and so the the normal site-packages was not writeable due to a permissions issue.
The solution was to change ownership back to the user doing pip install.
I met exactly the same issue.
I just type sudo python3.8 -m pip install .... and the error disappeared.
If I remove the sudo, issue remains.
For those running on a Pi, that accidentally installed pip as root. Just chown the lib folder to the pi user:
sudo chown -R pi:pi /usr/local/lib/python3.9/
in my case python3 -m pip install [package_name] did not solve that.
in my case, it was a problem related to other processes occupying the directory.
I restart Pycharm and close any other program that might occupy this folder, and reinstalled the package in site-packages directory successfully.
When this problem occurred to me I have tried all the mentioned approaches but they don't seem to work.
Instead, restarting Python language server in my VSCode did the job - my SimPy package is now found. On Mac it is Cmd+Shift+P and select "Python: Restart Language Server".
Had similar issue on Ubuntu 20.04.4 LTS in VirtualBox, but none of the suggestions here worked for me.
I was trying to install open3d in a venv and every time I was getting
"Defaulting to user installation because normal site-packages is not writeable"
which at first I didn't even noticed. open3d was always being installed in /usr/bin/python3 environment. I've restarted the VM but without luck, so I guess the problem was not just missing write access.
So in VS Code, which was using the venv, importing open3d was not possible. But testing from terminal from the activated venv with python3 -c "import open3d as o3d; print(o3d.__version__)" was working fine and that confused me totally. I even broke my system pip installation using sudo, see further below if you want to know how to fix it.
Anyhow, the solution to my problem was to explicitly point to the python3 file in the venv where I wanted to install the package:
venv/bin/python3 -m pip install open3d
So I was testing out everything and eventually installed with sudo: sudo pip3 install open3d. This of course didn't solved the problem and open3d was still missing in the venv. Even worse, I got the message:
"WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command."
So I did it but with sudo, updating the system pip and then found out here that this is not good:
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Following an advice here, I tried to revert to original version, only then pip3 broke:
sudo pip3 uninstall pip
sudo pip3 --version
sudo: pip3: command not found
The apt package was still there:
sudo apt install python3-pip python3-pip is already the newest version
(20.0.2-5ubuntu1.6).
So I had to reinstalled to fix the problem:
sudo apt-get remove python3-pip
sudo apt install python3-pip
Maybe you have python, python3, pip or pip3 aliased. In that case pip might not work well anymore, as the alias isn't always available and so pip/pip3 might resolve python/python3 differently compared to in your terminal.
That could give rise to pip/pip3 trying to install in the system python, and that could give rise to your error.
I tried ever single recommendation described here. In every instance, I get the exact same result: SyntaxError: invalid syntax (<stdin>, line 1)
I'm not sure who designed the system like this, but it seems basically useless, based on my experience so far. Either create a system that works, or don't create anything at all.
I am trying to create a virtual environment using virtualenv on Mac OS X El Capitan. I have installed Python 2.7.11 with brew, which includes pip, wheel and setuptools by default.
Hovewer, when I try to install virtualenv following instructions in the documentation or from any other resource, I get several problems:
virtualenv executable is not placed in /usr/local/bin after pip makes its job, so I need to ln -s it by hand (it may indicate, that there is something wrong with installation on this step).
After I run virtualenv venv, it creates new environment, catches Python 2.7.11 from brew-installation, but: there is no pip inside bin folder. That means, that if I try which pip, having venv activated, it returns a global position of pip — /usr/local/bin/pip, not /path/to/venv/bin/pip.
As a consequence, installing packages inside venv uses global pip and installs them to a global sites-packages, not that inside venv, and it's quite the opposite of what environment should do.
Could you please suggest what may be wrong and how to fix it?
EDIT: The thing to mention is that I used to have other versions of Python installed on my computer, which I have recently deleted as it is described in this answer. Maybe it causes the issue, and some more thorough cleaning is needed.
Try removing or renaming the .pydistutils.cfg file in your home directory, e.g. by renaming with mv ~/.pydistutils.cfg ~/oldpydistutils.cfg
I'm putting a detailed answer here to help others, but the original credit goes to this answer. If you know what specifically in .pydistutils.cfg was causing the problem, let me know!
I was having the same issue: my virtual environments were created without a local copy of pip, although they had a local copy of python. This meant that using $ pip from within the virtual environment installed to the global package location, and was not visible to the environment's python.
How I diagnosed this on my machine:
I create a virtualenvironment with $ virtualenv env
Activated the virtual environment with $ source env/bin/activate
Checked python location: run (env)$ which python with output /Users/<username>/env/bin/python (as expected)
Checked pip location: run (env)$ which pip with output /usr/local/bin/pip (NOT expected)
To check where our packages are going, we can try to install a package in the virtual environment:
Try to install a package: (env)$ pip install HTTPServer which succeeds
Try to run the package: (env)$ python -m HTTPServer which fails with error /Users/emunsing/env/bin/python: No module named HTTPServer
To double-check, try to install again: (env)$ pip install HTTPServer which produces Requirement already satisfied (use --upgrade to upgrade): HTTPServer in /usr/local/lib/python2.7/site-packages
Double-checking, we see that there's no Pip in the environment's /bin folder:
$ ls env/bin
activate activate.fish python python2
activate.csh activate_this.py python-config python2.7
And so while the system finds the local python version, it can't find a local pip to use and traverses the $PATH. It ended up using pip from /usr/local/bin, leaving me unable to install packages locally to the virtual environment.
Here's what I tried:
- Reinstalling python brew uninstall python followed by brew upgrade and brew install python --build-from-source
- Installing pip using the get-pip.py command as described in the Pip documentation
Here's what I ruled out:
- I was not using sudo pip ... which caused similar problems in this other question and haven't done so at any time on this Python/pip install
- My virtual environment didn't show a local installation of pip, as was the case in these similar questions: This one for Windows, This one for Mac OS X.
Ultimately, I found that eliminating the ~/.pydistutils.cfg file fixed the problem, allowing for fresh virtual environments that had their own local pip. The contents of my ~/.pydistutils.cfg file were:
[global]
verbose=1
[install]
install-scripts=$HOME/bin
[easy_install]
install-scripts=$HOME/bin
Simply renaming the ~/.pydistutils.cfg file appears to fix the problem: it seems that although this file was created by the homebrew installation, some settings in this file may be incompatible with virtualenv. While removing this file hasn't had any bad effects on my system, you may need to use the --user flag when installing packages with pip to the global environment (e.g. $ pip install --user HTTPServer). Here are more details on .pydistutils.cfg if you want to work on tailoring it for your needs.
virtualenv executable is not placed in /usr/local/bin after pip makes its job, so I need to ln -s it by hand (it may indicate, that there is something wrong with installation on this step).
Don't do that. That will only hide the bug and not solve the problem. Here's a short guide how to debug this kind of issues:
Start with which -a python. The first path you see should be /usr/local/bin/python, if not check your PATH variable.
Next, check which -a pip. Again the first path should be /usr/local/bin/pip. If not, run python -m ensurepip and recheck.
Now install virtualenv using pip install virtualenv, after that check the output of which -a virtualenv. The first path should be /usr/local/bin/virtualenv, if not check the output of env |grep PYTHON for unexpected environment variables.
Finally check the output of virtualenv --version to make sure you have the latest version.
I had the issue when running virtualenv: "ImportError: No module named pip."
My solution was to downgrade virtualenv. I had 16.2.0.
pip uninstall virtualenv
pip install virtualenv==15.1.0
Just hit same issue on Linux. Seems like there are multiple causes of this issue, but for me answer was to remove ~/.pip/.
Details: I had this in my .pip/pip.conf for some reason I can't remember:
$ cat ~/.pip/pip.conf
[global]
use_https = True
index = https://pypi.python.org/pypi
prefix = /home/sam/local/
and was using local versions on Python, Pip installed at ~/local/. For some reason virtualenv installed pip must pick up prefix = /home/sam/local/ setting and pip was being installed there.
Try this: sudo apt install pythonV.v-distutils.
In my case V.v == 3.8.
This worked for me.
I'm looking for a way to make a virtualenv which will contain just some libraries (which I chose) of the base python installation.
To be more concrete, I'm trying to import my matplotlib to virtualenv during the creation of virtualenv. It can't be installed efficiently with pip or easy_install since it misses some fortran compiler libs. The way I did it until now was to manually copy from:
/usr/lib/python2.7/dist-packages/ to virtualenv_name/lib/python2.7/dist-packages/
However this prevents the manully imported links to be registerd by yolk (which prints all currently available libs in virtualenv).
So, is there a way to do a selective variant of the
virtualenv --system-site-packages
Create the environment with virtualenv --system-site-packages . Then, activate the virtualenv and when you want things installed in the virtualenv rather than the system python, use pip install --ignore-installed or pip install -I . That way pip will install what you've requested locally even though a system-wide version exists. Your python interpreter will look first in the virtualenv's package directory, so those packages should shadow the global ones.
You can use the --system-site-packages and then "overinstall" the specific stuff for your virtualenv. That way, everything you install into your virtualenv will be taken from there, otherwise it will be taken from your system.
I am late to the game using python.3.8 and pip3 on Ubuntu 20.04.
The ONLY way to get rid of the annoying .local install for me was to set an environment variable (bash):
export PYTHONNOUSERSITE="true"
This does not need to be "true" anything will work. I would not go for a 0. ;-)
Install virtual env with
virtualenv --system-site-packages
and use pip install -U to install matplotlib
I know the obvious answer is to use virtualenv and virtualenvwrapper, but for various reasons I can't/don't want to do that.
So how do I modify the command
pip install package_name
to make pip install the package somewhere other than the default site-packages?
The --target switch is the thing you're looking for:
pip install --target=d:\somewhere\other\than\the\default package_name
But you still need to add d:\somewhere\other\than\the\default to PYTHONPATH to actually use them from that location.
-t, --target <dir>
Install packages into <dir>. By default this will not replace existing files/folders in <dir>.
Use --upgrade to replace existing packages in <dir> with new versions.
Upgrade pip if target switch is not available:
On Linux or OS X:
pip install -U pip
On Windows (this works around an issue):
python -m pip install -U pip
Use:
pip install --install-option="--prefix=$PREFIX_PATH" package_name
You might also want to use --ignore-installed to force all dependencies to be reinstalled using this new prefix. You can use --install-option to multiple times to add any of the options you can use with python setup.py install (--prefix is probably what you want, but there are a bunch more options you could use).
Instead of the --target or --install-options options, I have found that setting the PYTHONUSERBASE environment variable works well (from discussion on a bug regarding this very thing):
PYTHONUSERBASE=/path/to/install/to pip install --user
(Or set the PYTHONUSERBASE directory in your environment before running the command, using export PYTHONUSERBASE=/path/to/install/to)
This uses the very useful --user option but tells it to make the bin, lib, share and other directories you'd expect under a custom prefix rather than $HOME/.local.
Then you can add this to your PATH, PYTHONPATH and other variables as you would a normal installation directory.
Note that you may also need to specify the --upgrade and --ignore-installed options if any packages upon which this depends require newer versions to be installed in the PYTHONUSERBASE directory, to override the system-provided versions.
A full example
PYTHONUSERBASE=/opt/mysterypackage-1.0/python-deps pip install --user --upgrade numpy scipy
..to install the scipy and numpy package most recent versions into a directory which you can then include in your PYTHONPATH like so (using bash and for python 2.6 on CentOS 6 for this example):
export PYTHONPATH=/opt/mysterypackage-1.0/python-deps/lib64/python2.6/site-packages:$PYTHONPATH
export PATH=/opt/mysterypackage-1.0/python-deps/bin:$PATH
Using virtualenv is still a better and neater solution!
To pip install a library exactly where I wanted it, I navigated to the location I wanted the directory with the terminal then used
pip install mylibraryName -t .
the logic of which I took from this page: https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/download
Installing a Python package often only includes some pure Python files. If the package includes data, scripts and or executables, these are installed in different directories from the pure Python files.
Assuming your package has no data/scripts/executables, and that you want your Python files to go into /python/packages/package_name (and not some subdirectory a few levels below /python/packages as when using --prefix), you can use the one time command:
pip install --install-option="--install-purelib=/python/packages" package_name
If you want all (or most) of your packages to go there, you can edit your ~/.pip/pip.conf to include:
[install]
install-option=--install-purelib=/python/packages
That way you can't forget about having to specify it again and again.
Any excecutables/data/scripts included in the package will still go to their default places unless you specify addition install options (--prefix/--install-data/--install-scripts, etc., for details look at the custom installation options).
Tested these options with python3.5 and pip 9.0.3:
pip install --target /myfolder [packages]
Installs ALL packages including dependencies under /myfolder. Does not take into account that dependent packages are already installed elsewhere in Python. You will find packages from /myfolder/[package_name]. In case you have multiple Python versions, this doesn't take that into account (no Python version in package folder name).
pip install --prefix /myfolder [packages]
Checks if dependencies are already installed. Will install packages into /myfolder/lib/python3.5/site-packages/[packages]
pip install --root /myfolder [packages]
Checks dependencies like --prefix but install location will be /myfolder/usr/local/lib/python3.5/site-packages/[package_name].
pip install --user [packages]
Will install packages into $HOME:
/home/[USER]/.local/lib/python3.5/site-packages
Python searches automatically from this .local path so you don't need to put it to your PYTHONPATH.
=> In most of the cases --user is the best option to use.
In case home folder can't be used because of some reason then --prefix.
pip3 install "package_name" -t "target_dir"
source - https://pip.pypa.io/en/stable/reference/pip_install/
-t switch = target
Nobody seems to have mentioned the -t option but that the easiest:
pip install -t <direct directory> <package>
pip install packageName -t pathOfDirectory
or
pip install packageName --target pathOfDirectorty
Just add one point to #Ian Bicking's answer:
Using the --user option to specify the installed directory also work if one wants to install some Python package into one's home directory (without sudo user right) on remote server.
E.g.,
pip install --user python-memcached
The command will install the package into one of the directories that listed in your PYTHONPATH.
Newer versions of pip (8 or later) can directly use the --prefix option:
pip install --prefix=$PREFIX_PATH package_name
where $PREFIX_PATH is the installation prefix where lib, bin and other top-level folders are placed.
To add to the already good advice, as I had an issue installing IPython when I didn't have write permissions to /usr/local.
pip uses distutils to do its install and this thread discusses how that can cause a problem as it relies on the sys.prefix setting.
My issue happened when the IPython install tried to write to '/usr/local/share/man/man1' with Permission denied. As the install failed it didn't seem to write the IPython files in the bin directory.
Using "--user" worked and the files were written to ~/.local. Adding ~/.local/bin to the $PATH meant I could use "ipython" from there.
However I'm trying to install this for a number of users and had been given write permission to the /usr/local/lib/python2.7 directory. I created a "bin" directory under there and set directives for distutils:
vim ~/.pydistutils.cfg
[install]
install-data=/usr/local/lib/python2.7
install-scripts=/usr/local/lib/python2.7/bin
then (-I is used to force the install despite previous failures/.local install):
pip install -I ipython
Then I added /usr/local/lib/python2.7/bin to $PATH.
I thought I'd include this in case anyone else has similar issues on a machine they don't have sudo access to.
If you are using brew with python, unfortunately, pip/pip3 ships with very limited options. You do not have --install-option, --target, --user options as mentioned above.
Note on pip install --user
The normal pip install --user is disabled for brewed Python. This is because of a bug in distutils, because Homebrew writes a distutils.cfg which sets the package prefix.
A possible workaround (which puts executable scripts in ~/Library/Python/./bin) is:
python -m pip install --user --install-option="--prefix=" <package-name>
You might find this line very cumbersome. I suggest use pyenv for management.
If you are using
brew upgrade python python3
Ironically you are actually downgrade pip functionality.
(I post this answer, simply because pip in my mac osx does not have --target option, and I have spent hours fixing it)
With pip v1.5.6 on Python v2.7.3 (GNU/Linux), option --root allows to specify a global installation prefix, (apparently) irrespective of specific package's options. Try f.i.,
$ pip install --root=/alternative/prefix/path package_name
I suggest to follow the documentation and create ~/.pip/pip.conf file. Note in the documentation there are missing specified header directory, which leads to following error:
error: install-base or install-platbase supplied, but installation scheme is incomplete
The full working content of conf file is:
[install]
install-base=$HOME
install-purelib=python/lib
install-platlib=python/lib.$PLAT
install-scripts=python/scripts
install-headers=python/include
install-data=python/data
Unfortunatelly I can install, but when try to uninstall pip tells me there is no such package for uninstallation process.... so something is still wrong but the package goes to its predefined location.
pip install /path/to/package/
is now possible.
The difference with this and using the -e or --editable flag is that -e links to where the package is saved (i.e. your downloads folder), rather than installing it into your python path.
This means if you delete/move the package to another folder, you won't be able to use it.
system` option, that will install pip package-bins to /usr/local/bin thats accessible to all users. Installing without this option may not work for all users as things go to user specific dir like $HOME/.local/bin and then it is user specific install which has to be repeated for all users, also there can be path issues if not set for users, then bins won't work. So if you are looking for all users - yu need to have sudo access:
sudo su -
python3 -m pip install --system <module>
logout
log back in
which <module-bin> --> it should be installed on /usr/local/bin/
Sometimes it works only works with Cache argument
-m pip install -U pip --target=C:\xxx\python\lib\site-packages Pillow --cache-dir C:\tmp