# pip

#### Installation

Tutorials

- [Install packages in a virtual environment using pip and venv - Python Packaging User Guide](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/)

NOTE: The following commands still require internet connection.

##### get-pip.py

```shell
# Latest version of python
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

# For python 2.7.x
curl https://bootstrap.pypa.io/2.7/get-pip.py -o get-pip.py

# Offline Install the pip
sudo pyhon get-pip.py

# Install pip
python3 -m pip install pip
```

Update the pip

```bash
pip install --upgrade pip

python3 -m pip install --upgrade pip
```

#### Module install

```shell
# Downloading the source files required for the module mkdocs, which requires an internet.
pip download -d <output-dir> mkdocs

# Offline install the module mkdocs
pip install <output-dir>/*.whl

```

#### Proxy server

```bash
pip install --proxy http://<usr_name>:<password>@<proxyserver_name>:<port#> <pkg_name> 
```

```bash
pip config set global.proxy http://account:password@xxx.com.tw:8080
pip config set global.trusted-host pypi.python.org\npypi.org\nfiles.pythonhosted.org
```

#### Command

List installed modules

```bash
sudo pip list
```

Upgrade module

```bash
sudo pip install --upgrade <MODULENAME>
```

Export the list of installed modules

```bash
pip freeze > requirements.txt
```

Install modules in requirements.txt

```bash
pip install -r requirements.txt
```

Check if the specified module was already installed

```bash
python3 -c "import tensorrt_llm"
```

#### Q &amp; A

> ERROR: Could not find a version that satisfies the requirement XXXX (from versions: none)

執行 `pip install XXXX` 時發生上述錯誤。

Solution:

改成這個指令：`python -m pip install XXXX`