Home >Backend Development >Python Tutorial >Where to install third-party libraries in python
Where to install third-party libraries?
Python’s third-party libraries are mainly installed in the following two directories:
~/.local/lib/ python3.x/site-packages
/usr/local/lib/python3.x/site-packages
How to install third-party libraries?
There are several methods to install third-party libraries:
1. Use pip
pip is Python’s built-in package management tool . To install third-party libraries using pip, follow these steps:
<code># 确保已安装 pip python -m ensurepip # 使用 pip 安装第三方库 pip install <包名></code>
2. Using conda
conda is a package and environment management tool that comes with the Anaconda distribution . To install third-party libraries using conda, follow these steps:
<code># 创建或选择一个 conda 环境 conda create -n <环境名> python=3.x # 使用 conda 安装第三方库 conda install -c <频道名> <包名></code>
3. Install from source
Some third-party libraries can be installed by installing from source . To install a third-party library from source, follow these steps:
<code>python setup.py install</code>
Select the installation directory
By default, third-party libraries will Installed in the user directory. If you wish to install the library in a system directory, you can use the --target
option:
<code>pip install --target=/usr/local/lib/python3.x/site-packages <包名></code>
Repositories and Channels
The above is the detailed content of Where to install third-party libraries in python. For more information, please follow other related articles on the PHP Chinese website!