How to change the python version of already existing virtualenv? [duplicate]

♀尐吖头ヾ 提交于 2019-11-28 11:26:32

See this link which explains it well.

Virtualenvwrapper comes with some convenient commands for managing your virtualenvs.

To change your Python version:

  1. Deactivate your current environment session.

  2. If you have many packages or libraries installed, it would be a good idea to make a requirements.txt file. Remember to edit version as necessary.

  3. Remove the virtualenv with the wrapper command: rmvirtualenv

    • This will remove the virtualenv, but leave your project files.
  4. Make a new virtualenv with the Python version you want.

    • Example: mkvirtualenv -p python3 env-name

    • You can specify the Python version with the -p flag and version. If you have a requirements.txt file, you can specify that with -r requirements.txt

  5. Now bind your new virtualenv to your project directory. You can specify the full paths, but it is easier to have your new virtualenv activated and be in your project directory. Then, run the command:

Example: setvirtualenvproject

Please let me/us know if this answer was helpful to you!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!