1ang
1ang

Reputation: 321

Django runs with wrong python version

I run the django on my ubuntu server. On the server, there are two different versions of python, which are python 2.x and 3.x. I use the request module of 3.x, but the server default uses the python of 2.x that occurs the error. How can that be solved? Thanks

I run the django with apache server, and here is the configuration.

Alias /static/ /python_web/person-blog/mysite/blog/static/

<Directory /python_web/person-blog/mysite/blog/static>
    Require all granted
</Directory>

WSGIScriptAlias / /python_web/person-blog/mysite/mysite/wsgi.py
WSGIDaemonProcess xxx.com python-path=/python_web/person-blog/mysite:/python_web/env/lib/python3.4/site-packages
WSGIProcessGroup xxx.com

<Directory /python_web/person-blog/mysite/mysite>
<Files wsgi.py>
    Require all granted
</Files>
</Directory>

Upvotes: 2

Views: 1333

Answers (1)

Charlotte Mays
Charlotte Mays

Reputation: 385

You will point your server to the correct python interpreter. How that is done will depend on the server software you are using. This tutorial shows the apache configuration, close to the bottom of the page. Note the "python-path" being designated.

https://www.digitalocean.com/community/tutorials/how-to-run-django-with-mod_wsgi-and-apache-with-a-virtualenv-python-environment-on-a-debian-vps

If you're running a server other than apache, then the answer will be similar. Just do a search for the server software you're using and "python interpreter" and you should be able to find your answer.

Upvotes: 1

Related Questions