Hello, I’m Yue Chuang.

Export all dependent packages

Dependency package export for the entire environment

Go to the project directory and run the following command:

pip freeze > requirements.txt
Copy the code

Then in the current directory, you can see the generated “requirements. TXT” file. If you open it, you will see a lot of package information. In fact, this is an export of all the package information for your current Python environment. If we just export the dependency packages needed for the current project, I can take a different approach.

Export only the dependency packages required by the project

Go to the project directory and run the following command:

pipreqs ./
Copy the code

By default, the “pipregs” plug-in is not installed, so the following error will be displayed:

pipreqs: command not found
Copy the code

Therefore, we need to install the plug-in by executing the following command:

pip install pipreqs
Copy the code

Note: if you have multiple virtual environments, you need to enter the specified virtual environment to install, otherwise it will not work.

Once installed, we export dependencies by executing the following command:

pipreqs ./
Copy the code

Wait a little while to export successfully:

If you open the “requirements.tx” file, you’ll see that much of the extra dependency package information is missing.

Importing dependency packages

We can use the “requirements. TXT” file above to import dependencies and quickly build up the environment. This is especially handy when we need to move the project to another environment for deployment.

My_py37_test = my_py37_test = my_py37_test = my_py37_test = my_py37_test = my_py37_test = my_py37_test = my_py37_test

We can do this by using the following command:

pip install -r requirements.txt
Copy the code

When we run the code again, we can see that there is no problem.

AI yue chuang has launched tutorial classes, including “Python language tutorial, C++ tutorial, algorithm/data structure tutorial”, all one-to-one teaching: one-to-one tutoring + one-to-one q&a + assignment + project practice, etc. QQ, wechat online, response at any time! V:Jiabcdefh