Installing Python Packages in Non-Default Directories with Pip
Installing Python packages into a specific directory, rather than the default site-packages, can provide benefits such as segregation or compatibility. While using virtualenv and virtualenvwrapper is a common solution, this may not be feasible in all cases.
To modify the pip command for package installation outside the default site-packages, the --target switch comes into play:
pip install --target <dir> <package_name>
where
The --target switch is a valuable tool for controlling package installation locations. Older versions of pip may not support this option. In such cases, it's recommended to upgrade pip:
Linux or OS X:
pip install -U pip
Windows (to circumvent an issue):
python -m pip install -U pip
The above is the detailed content of How Can I Install Python Packages to a Custom Directory Using Pip?. For more information, please follow other related articles on the PHP Chinese website!