Home > other >  If i have many different virtual enviroments in my computer, how to make sure a django project is us
If i have many different virtual enviroments in my computer, how to make sure a django project is us

Time:10-12

I have established 5 virtual environments in a folder using the command line, and then start a Django project outside of the folder how can I make sure which virtual env I am using in this Django project if the project is not using any virtual env in the folder, how can I change (make some configurations) the project's virtual env to a specific one in the folder?

PyCharm pro will automatically establish the link between Django project and virtual env, but what if I am using a community version, how can I make it clear that which Django project is using which virtual env?

I think I have the same problem in this question from StackOverflow: How to make sure that my django project is using virtual environment that i created for it?

If anyone knows this and could give me some explanation that would be great.

CodePudding user response:

You can create virtuals env like:

python3 -m venv myvenv1
# pip install -r requirements.txt
python3 -m venv myvenv2
# pip install -r requirements.txt

for serve django (development)

source myvenv1/bin/activate

python3 manage.py runserver

or

source myvenv2/bin/activate
python3 manage.py runserver

CodePudding user response:

This takes some guesswork The first step is that you must use a CMD board from the same path as yours Let me explain it better to you

I have five virtual environments Inside each one are my work files But to start working on my project, I need to activate this virtual environment and then go to the project files themselves.

FROM CMD I'LL WRITE ./Scripts/activate #win

then I going to file e.g. src

just go to sittings.py file and look at BASE_DIR => this is what is your dir right now

print it out

print(BASE_DIR)

I hope I understood your problem and helped you understand it more

  • Related