开发者社区> 问答> 正文

在virtualenv中默认更改python版本

我在使用python2.7初始化的项目中使用virtualenv,现在我想默认使用python3.5更改项目的python版本!任何人都可以帮助我!

问题来源:stackoverflow

展开
收起
is大龙 2020-03-23 16:48:05 1021 0
1 条回答
写回答
取消 提交回答
  • 您可以使用以下命令:

    mkvirtualenv -p python3 env-name
    

    更改Python版本的详细说明:

    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 `

    这将删除virtualenv,但保留您的项目文件。

    1. Make a new virtualenv with the Python version you want.

    例如:mkvirtualenv -p python3 env-name

    您可以使用-p标志和版本来指定Python版本。如果您有一个requirements.txt文件,则可以使用-r requirements.txt`进行指定。

    1. 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:

    例如:setvirtualenvproject

    来源在这里

    回答来源:stackoverflow

    2020-03-23 16:48:10
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载