简体   繁体   中英

Setting up Virtual Environment for Django in python

enter image description here please help

python3 -m venv venv

In the main directory root add the following command to create the environment:

$ python3 -m venv venv this code will create a folder called venv in the root. Which basically is the virtual environment folder.

Then add the following command to activate the virtual environment:

$ source venv/bin/activate

your_project_folder/
 |
 |-- your_main_app_folder/
 |         |
 |         |--Folder_with_controllers/
 |         |            settings.py
 |         |            urls.py
 |         |            ...
 |         | 
 |         |--App_folder/
 |         |--Other_app_folder/
 |
 |--venv/

If the code works fine your bash should look like this: (venv) <the_path_for_the_folder> your_project_folder

After activated your environment you can now install django and other packages.

Ps: make sure you instal and activate the virtual environment folder not in the your_main_app_folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM