V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
miniyao
V2EX  ›  Python

python3 -m venv /path/venv 如何选择 Python3.3 或 Python3.7 版本号呢?

  •  
  •   miniyao · 2020-04-29 15:16:52 +08:00 · 3233 次点击
    这是一个创建于 1429 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在系统里 /usr/bin/ 中有 Python3.3 和 Python3.7 两个 py 版本,在创建 venv 时,如何指定 Python3.3 或 Python3.7 呢?

    官方文档里也没找到说明,这个命令能指定 Python3.* 的小版本吗?

    python3 -m venv /path/venv
    
    11 条回复    2020-04-30 10:01:11 +08:00
    raycool
        1
    raycool  
       2020-04-29 15:37:35 +08:00
    python3 这个引用的是哪个版本创建的就是哪个吧
    rrfeng
        2
    rrfeng  
       2020-04-29 15:39:20 +08:00   ❤️ 1
    python3.3 -m venv
    python3.7 -m venv
    hyfc
        3
    hyfc  
       2020-04-29 15:44:44 +08:00
    -p PYTHON_EXE, --python=PYTHON_EXE
    The Python interpreter to use, e.g.,
    --python=python3.5 will use the python3.5 interpreter
    to create the new environment. The default is the
    interpreter that virtualenv was installed with
    (/usr/bin/python2)
    miniyao
        4
    miniyao  
    OP
       2020-04-29 15:46:21 +08:00
    @raycool
    @rrfeng
    @hyfc

    官网文档没看到,在 askubuntu 上看到是这样的
    hyfc
        5
    hyfc  
       2020-04-29 15:51:02 +08:00
    使用 python3 内置 venv 库的话,就按照 2 楼的方法指定解释器版本。如果用 virtualenv 命令行,可以用-p 参数
    xpresslink
        6
    xpresslink  
       2020-04-29 16:33:19 +08:00
    如果默认要用 3.7 可以创建一个软连接
    # rm /usr/bin/python3
    # ln -s /usr/bin/python3.7 /usr/bin/python3
    wellsc
        7
    wellsc  
       2020-04-29 16:39:53 +08:00
    $ whereis python
    $ /pathto/python3.7 -m venv ./somevenv
    Mark24
        8
    Mark24  
       2020-04-29 16:46:24 +08:00
    推荐一个终极方案。。。解决所有语言,版本的虚拟环境

    https://asdf-vm.com/
    laike9m
        9
    laike9m  
       2020-04-29 17:16:13 +08:00
    无责任推荐一下 @frostming 的 pdm,从此告别虚拟环境
    https://github.com/frostming/pdm
    ruanimal
        10
    ruanimal  
       2020-04-29 18:02:33 +08:00
    使用绝对路径启动 python 吧
    chenglus
        11
    chenglus  
       2020-04-30 10:01:11 +08:00
    在?为什么不用 pyenv ?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3238 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 12:05 · PVG 20:05 · LAX 05:05 · JFK 08:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.