2

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>
1ang
  • 321
  • 2
  • 3
  • 11
  • Can you please give more details on your configuration: Are you using Apache, Nginx or Django's own debug server? Are you using mod_wsgi? Ideally, can you give your configuration files (e.g. in /etc/apache2/sites-enabled/)? – raphv Jul 06 '16 at 15:50
  • @raphv sorry about that, I have updated the question ^_^ – 1ang Jul 06 '16 at 16:14
  • Are you sure mod_wsgi is installed and configured for Python3? See http://stackoverflow.com/questions/19344252/how-to-install-configure-mod-wsgi-for-py3 – raphv Jul 06 '16 at 16:18
  • @raphv Yes, I think so. If I use the request with 2.x, the web runs well. – 1ang Jul 06 '16 at 16:21
  • @raphv Oh, that may be the key to the problem, I will try that, thanks dude – 1ang Jul 06 '16 at 16:22

1 Answers1

1

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.

Charlotte Mays
  • 325
  • 4
  • 11