简体   繁体   中英

Confused with virtual environments in python django

I have my Django project folder and inside that i have my virtualenv folder

I have few questions

  1. I have packages already installed in main installation and as well in virtual env. Dont those packages mix with each other. I mean if i have old version in main installation and new version in virtual env how does the system knows which one to choose

  2. Suppose i move my project folder to new computer than can i use same virtual env folder because it was in the same app directory or i have to start all over again

  3. How will i know that pip install package to virtual env or main installation

  1. Unless you created the virtualenv with --system-site-packages, packages don't mix at all. If they did, Virtualenv has priority.

  2. If the path doesn't change, there are chances that you can reuse it. You could make a virtualenv --relocatable if the path changes. But you should make a requirements file and be able to regenerate a fresh virtualenv in one pip -r req.txt command.

  3. If a virtualenv is activated, pip will install in the virtualenv, it has priority.

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