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
magicdu
V2EX  ›  Python

pip 和 pip3 同时安装 Django 的问题,建工程怎么指定 Python 版本啊

  •  1
     
  •   magicdu ·
    magicdu · 2017-03-09 18:56:43 +08:00 · 2503 次点击
    这是一个创建于 2612 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Python2.7 用 pip 安装了 Django,Python3.5 用 pip3 安装了 Django ,然后建工程

    django-admin startproject mysite
    
    

    比如我想同时建一个 2.7 的工程和 3.5 的工程。怎么指定 Python 版本啊。

    qweweretrt515
        1
    qweweretrt515  
       2017-03-09 19:03:35 +08:00
    环境变量
    patrickstar
        2
    patrickstar  
       2017-03-09 19:11:46 +08:00
    恐怕 pyvenv 或 virtualenv 才是解决之道哦
    shoaly
        3
    shoaly  
       2017-03-09 20:58:19 +08:00
    virtualenv 应该是一个 prework 了.
    Kilerd
        4
    Kilerd  
       2017-03-09 22:25:12 +08:00
    建议用 pyenv 来管理多个版本的 python 环境
    siteshen
        5
    siteshen  
       2017-03-10 00:21:37 +08:00
    看了一下 django-admin 文件的源码, django-admin 文件在 python2 和 python3 下都能跑,所以能这么做:

    python2 $(which django-admin)
    python3 $(which django-admin)

    当然,还是维护多个项目,还是推荐使用 virtualenv 。
    zsz
        6
    zsz  
       2017-03-11 19:02:35 +08:00 via iPhone
    看一下 https://www.u3v3.com/ar/1256
    点我头像,看简介,可以加群沟通,这样效率比较高
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   828 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:15 · PVG 06:15 · LAX 15:15 · JFK 18:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.