Detailed explanation of common pip instructions - (pip install -e. etc.)

Table of contents

1. pip command

1.1 pip install -e .

1.1.1 Background

1.1.2 Examples

1.2 pip list

 1.3 pip install -r requirements.txt

1.3.1 Background

1.3.2 Actual combat


1. pip command

You can enter pip install --help or pip3 install --help  in the terminal to view the pip manual.

1.1 pip install -e .

1.1.1 Background

When downloading the code from github, I saw it in quick_start, pip install -e. I checked this command because I had never come across it before.

 -e followed by . means that the current project will be installed into the current python environment as a soft link and can be modified. In a word, this command will execute the setup.py file in the current directory . What to do depends on setup.py How to write it? After the installation is completed, by executing pip list, you can see that the current project is installed in the python environment.

1.1.2 Examples

operation result:

1.2 pip list

List installed packages

 1.3 pip install -r requirements.txt

If you want to understand this instruction, it is recommended to carefully read the 2.4 virtual environment migration packaging of the following blog : Detailed graphic explanation of python's virtual environment (virtual environment function and virtual environment setup, switching, exit, migration packaging) code demonstration_python switching virtual environment_Rebecca_yanhan's Blog-CSDN Blog

1.3.1 Background

Usually when we use python, we will use a virtual environment. When it comes to virtual environment packaging and migration issues, how to completely package and migrate the packages required by a python project, you can use the following instructions

1.3.2 Actual combat

#将安装包版本信息导入到requireents.txt文件中,注意 --all 参数,加上此参数会将setuptools、#urllib3包进行打包;如果不加,这两个不会打包

pip freeze --all > requirements.txt

#再下载安装依赖包

pip install -r requirements.txt 

Use the following command in the TransE_demo directory, 

You will find that a new file is generated

Then pip install this txt in the required directory.

Guess you like

Origin blog.csdn.net/weixin_45440484/article/details/130009424