Installing python3 in a python2 virtual environment

前端 未结 1 1445
一整个雨季
一整个雨季 2020-12-02 00:19

I have a Flask application that is running in a Python 2 virtual environment.

I\'m looking to run a Python 3 program, so I need to install python3 into the virtual

相关标签:
1条回答
  • 2020-12-02 00:36

    It's not recommended to mix multiple versions of Python. In fact, I don't think it's even possible.

    Creating a new virtualenv isn't difficult at all:

    1. Get the list of modules in the current virtualenv

      source /path/to/current/bin/activate
      pip freeze > /tmp/requirements.txt
      
    2. Create a new virtualenv. Either change into a suitable directory before executing the virtualenv command or give a full path.

      deactivate
      virtualenv -p python3 envname
      
    3. Install modules

      source envname/bin/activate
      pip install -r /tmp/requirements.txt
      

    That's it.

    0 讨论(0)
提交回复
热议问题