Python virtual environment installation and new django project under Windows

1. Install Python version 2.7

2. Use pip to install in the cmd command line: pip install virtualenv

3. Create a new virtual environment: vartualenv testvir

4. Enter the virtual environment: cd testvir

5. cd Scripts

6. activate.bat enters the virtual environment 

      as the picture shows: 


 

7. Exit as deactivate.bat

8. For virtual environment installation under Windows, you can use the workon command directly: Type the command:

pip install virtualenvwrapper-win 

9. Create a new virtual environment: mkvirtualenv testvir2

(You can see that the location of the changed environment is: C:\Users\wang\Envs\testvir2)

10. View all virtual environments: workon

11. Quickly enter the virtual environment: workon testvir2

12. Install the Python package after entering the virtual environment, pip install requests

13. Uninstall Python packages: pip uninstall requests

14. View all packages: pip list

15. Install django: pip install django==1.9.8

      The installation is complete as shown in the figure:

 

16. The environment location selected when pycharm creates the project is:

      G:\Users\wang\Envs\testvir2\Scripts\python.exe

      as the picture shows:

17. Click Create to create a django project

18. Click the Run menu run button under pycharm, as shown in the figure:



 19. In the input field of the development tool, you can see: Starting development server at http://127.0.0.1:8000/, it means that the project was started successfully.

20. Enter http://127.0.0.1:8000/ in the browser to access.

 

Note: The command for python3.6 to use pip is: pip3
 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326987654&siteId=291194637