Python tips for configuring project migration and deployment based on the Flask framework and dependency package information, pythonflask

Source: Internet
Author: User

Python tips for configuring project migration and deployment based on the Flask framework and dependency package information, pythonflask

After Coding Based on the Flask framework on the local machine, you need to deploy the code on the specified server if you need interfaces or data operations.

 

In general, most developers who use the Flask framework use the Python virtual environment to run projects. Different virtual environments have different configuration dependency package information. If you re-migrate to a new virtual environment and re-configure the dependency packages one by one, it will be a waste of time.

 

Next we will introduce a simple and easy-to-use technique that I can see in my own books to avoid having to read books every time I configure it. Therefore, I will write an article for record by myself, I hope to help other students.

 

After coding the project, open the local CMD and enter the project Virtual Environment Scripts directory. The specific operations are as follows:

 

 

Input

cd E:\WorkPlace\Git_python\MyDemo-ten\venv\Scripts

Enter the directory specified by the command above.

 

Then enter the command

activate

(PS: This command will display the virtual environment name before the path. For example, if my virtual environment name is venv, it will display (venv )).

 

Then enter the command cd ..

Enter the command cd again. (PS: cd .. indicates that the upper-level directory is returned. Two operations are performed to enter the root directory of the project ).

 

Finally, enter the command

pip freeze >requirements.txt

You can see a requirements.txt file under the project root directory. The file displays information about all configuration dependency packages of the project. For details, see:

 

 

Open ID e requirements.txt. For details, refer:

 

 

After the migration to a new environment, If you enable it with id e, the ID e will prompt the specified dependency package in the configuration and installation requirements.txt information, and click Install in the installation prompt. If you do not have a prompt or do not use id eto configure the environment, you can perform the operations in the newly created virtual environment from the environment, which is similar to creating the requirements.txt file in the Environment configuration, and then enter the command:

pip install -r requirements.txt

You can complete the dependency package configuration.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.