Upgrade Python from 2.7 to 3.4 - django runner is using 2.7


#1

Dear all,

I was just trying to run my Django project (which always runned), but I got an error that some packages were missing.
Then I saw that Django was running 2.7, while regular python was version 3.4. I guess this was a python upgrade from C9…

The runner itself has this code:
> {
> “cmd”: [
> “bash”,
> “–login”,
> “-c”,
> “$python manage.py syncdb && $python manage.py runserver $ip:$port”
> ],
> “working_dir”: “$project_path”,
> “info”: “Your code is running at \033[01;34m$url\033[00m.\n\033[01;31m”
> }

Changing $python to $python3.4 didn’t work. python -V gives me 3.4 already, but the error message looks like this:
> File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module

Any idea how to make Django run at 3.4?


#2

Hey @1David :smiley:,

Nice to e-meet. Did you choose the Cloud9 Django workspace template when starting your project?

Referencing these:

:books: :snail:

Not sure if it changed recently but when I chose the Django template it used python v2.7


#3

$python is automatically expanded to the python version configured in language support section of project settings
either use python3.4 or change the version from project settings


#4

I changed the Python version from the project settings to Python 3, restarted and the shell is still showing “Python 2.7.6”


#5

Hey @toledomatias :slightly_smiling:,

Referencing what Brady says about python versions:

I tried changing project settings and that couldn’t figure that out but I found how to run python commands from version 3.4:

mikeumus@mikeumus-website:/usr/local/lib $ python --version
Python 2.7.6
mikeumus@mikeumus-website:/usr/local/lib $ python3.4 --version
Python 3.4.0

I also found this in Cloud9 -> Project Settings -> Language Support -> Python Version:


#6

i changed project settings to use python 3 and when I type python in the terminal, it still says 2.7 – restarted the workspace – still 2.7


#7

this is really frustrating – we’re told to change project settings but typing in python still shows 2.7 and then you say to mv the system python to python2 then move python3 to system (and u say it’s in Brady’s article – when I clicked the title of the article those lines are not in there – theres a weird up and down arrow all the w ay to the right of the link that changes what is displayed – getting frustrated


#8

The setting in preferences is for choosing version of python used for langauge tooling that is linting and autocompletion

It can’t change the default installed version of python because there are many programs that do not work with python 3 (e.g. node-gyp), and most people use virtualenv anyway.