Home  >  Q&A  >  body text

python小问题 - 在阿里云的ubuntu机器上部署django,如何指定python版本?

请问一下如何在部署django的时候,指定python的运行版本?
阿里云默认的是使用python2.7的版本,但是我开发用的python3,但是我部署在apache上,老是运行2.7(因为是默认的),很多包和库都不兼容 很麻烦.

所以特此来求教一下!

巴扎黑巴扎黑2765 days ago701

reply all(4)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-17 17:55:40

    Install python3 first
    and then set up the soft link

    ln -s /usr/bin/python3 /usr/bin/python

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:55:40

    Compile and install Python 3 by yourself, and then use it to install django.

    Finally just specify it in the apache configuration file

    WSGIScriptAlias / /my/app/path/wsgi.py
    WSGIPythonPath /my/app:/path/to/the/virtual/env/lib/python3.3/site-packages
    

    PS: Python 3 support requires Django 1.6+ and mod_wsgi 3.4+
    link: http://stackoverflow.com/questions/5930585/how-to-use-python-3-and-django-with-apache/

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 17:55:40

    python3 yourCmd
    or you can consider virtualenv

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 17:55:40

    It is recommended to use virtualenv, you can specify the python version when creating

    reply
    0
  • Cancelreply