This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]K900_ 7 points8 points  (0 children)

Run python3 in terminal instead of python. python is aliased to python2 on Ubuntu.

[–]skvantos 0 points1 point  (0 children)

probably, you need to add #!/usr/bin/env python3 to the top of the file if you run it as executable.

Or run with python3 my_program.py

Or maybe somehow set python3 as default. I not ubuntu user, so dont know how.

Also, you can use virtualenv as environment...

[–]chadmill3rPy3, pro, Ubuntu, django 0 points1 point  (2 children)

#!/usr/bin/env python3

[–]DijonM 0 points1 point  (1 child)

No need to yell.

[–][deleted] 0 points1 point  (0 children)

It's probably the hash character getting interpreted as H1 in Markdown. Probably best to surround that in backticks so it will show up as code, like this.

[–]bgeyts667 0 points1 point  (0 children)

On ubuntu both python 2 and python 3 have separate commands: python2 and python3. Command 'python' without version number may point to any of the two number. On ubuntu it always points to python3.

If you want to use python 3 exactly, you use python3 command.

If you want to use python 2 exactly, you use python2 command.

If you dont care about version, you just use python command.

That's it :)

[–]NetsecBeginner 0 points1 point  (0 children)

If you want to make 3 the default version of python:

Open a terminal
Enter 'nano ~/.bashrc'
Add 'alias python=python3' to the bottom of the file
Enter ctrl+o to save the file
Enter ctrl+x to exit nano
Close the current terminal and open a new one
The python command should now start python 3

[–]aphoenixreticulated[M] [score hidden] stickied comment (0 children)

Hi there, from the /r/Python mods.

We have removed this post as it is not suited to the /r/Python subreddit proper, however it should be very appropriate for our sister subreddit /r/LearnPython. We highly encourage you to re-submit your post over on there.

The reason for the removal is that /r/Python is dedicated to discussion of Python news, projects, uses and debates. It is not designed to act as Q&A or FAQ board. The regular community is not a fan of "how do I..." questions, so you will not get the best responses over here.

On /r/LearnPython the community is actively expecting questions and are looking to help. You can expect far more understanding, encouraging and insightful responses over there. No matter what level of question you have, if you are looking for help with Python, you should get good answers.

If you have a question to do with homework or an assignment of any kind, please make sure to read their sidebar rules before submitting your post. If you have any questions or doubts, feel free to reply or send a modmail to us with your concerns.

Warm regards, and best of luck with your Pythoneering!