Python version in Linux Ubuntu 18. Swap python version from 2.7 to 3.x

Hey there,
I’m windows user for 10+ more years, and yesterday I got on Linux Ubuntu 18.04 LTS, to learn new things in programming. Before in Windows, I was working on Atom with python in 3.7 I think version, I was able to code the “basics” I started to make my own things. But after changing to Linux after getting the ATOM, i started to get an errors in my code, but in the Windows the code was tested, and it was working fine. So after doing a bit of research i found out that I have python 2.7 in the Atom editor, I found out by input(…) and raw_input(…) Commands, after switching from input to raw_input. So now I’m not really understanding the most things on Linux I’m trying to understand what should I do to fix this issue.
My Code:
# Royal AK47 SHOP.

Concept consist of Items in the Store. We call it STOCK

User we can call (BUYER) Buys something from the shop, and stock quanity is minusing, so we minus from it

import sys
import os
import getpass

import ctypes


#def clear(): return os.system(‘cls’)

ctypes.windll.kernel32.SetConsoleTitleW(“Royal AK-47 SHOP”)


print(“Welcome to Royal AK-47 SHOP”)

sTock market BuyCount

Total_AK47 = 30 # Stock
Total_Grenade = 15 # Stock
Total_Pizza = 5 # Stock
Total_Ammunition = 6000 # Stock

Our wallet

Bitcoin = 5000 # EUR
Paypal = 2500 # EUR


One_AK47 = 500 # EUR
One_Grenade = 250 # EUR
One_Pizza = 50 # EUR
One_Ammunition = 25 # EUR

Totalinius skaic.

Total_Stock = Total_AK47 + Total_Grenade + Total_Pizza + Total_Ammunition
Total_Products = 4

EUR Definitions

Ballance = Bitcoin + Paypal

Shoplist = [“ak”, “Grenade”, “Pizza”, “Ammunition”]
shoplistStockItems = len(Shoplist)
print("Checking stock items in shop - ", + shoplistStockItems)

Checking if there’s name in the BANLIST Which is currently in Listas_BAN

ban_path = ‘Listas_BAN.txt’ # be sure to replace by the full path
starterItems_path = “Starter Items.txt”

Classes and variables

def Banmessage():

def MoneyBalance():

Ban Rule.

Ban_Message_Rule = (
“For more information please contact one of our team\nFor any investiment our team works up.\n~ Please report if you discovered a bug.\n Our gmail -”)

name = input("~ Please enter Your name below\n")

password = getpass.getpass("~ Please pick a password, for user - {n}\n".format(n=name))

print(input("Please input a command: “).upper().replace(” ", “”))

print("~ Your password is - " + password)

city = input(’~ Where are you from?\n* NOTE - You should type correctly. * account recovery.\n’)

gmail = input("~ Please add your GMAIL Address.\n")

while True:
name = input("~ Please pick a Username\n")
if " " in name or len(name) <= 2:
print("~ Username can’t contain spaces!\n * Make sure You’re Username has not less then 3 Symbols, or letters!")


Password Create.

while True:
password = getpass.getpass("~ Please pick a password, for user - {n}\n".format(n=name))
if " " in password or len(password) <= 4:
print("~ Password can’t contain spaces!\n \n * Make sure You’re Password has not less then 5 Symbols, or letters!")


with open(ban_path, mode=‘r’, encoding=‘utf-8’) as f:
if name in
# Jeigu randa varda utf-8 formatu, tada duodam zinot, kad negalim test ir turim bana to zmogaus vardu.
print(’~ Sorry {n} your account has been banned’.format(n=name))
print(’~ Accepted {n}, your account does not have any previous reports.’.format(n=name))


age = input(str(name) + ",Please enter your age: ")

print("Welcome, {n}\nYour balance - {blc} EUR ".format(n=name, blc=Ballance))
age = int(age)

Age types

if age <= 18:
age_group = 'Young ’ # Neleidziam jam but cia.
print("~Sorry, you cannot buy anything.\n~Error: Your’e not under 18. “)
elif (age > 18) and (age <= 21):
age_group = 'Starter ’
print(”~What would you like to buy?\n Here is stuff for Your group -" + age_group)
# first_group = True
elif (age > 21) and (age < 40):
age_group = 'Experienced ’
# second_group = True
elif (age >= 40) and (age < 100):
age_group = ‘Professional Mode’
# third_group = True
elif(age >= 100) and (age <= 9999):
age_group = ‘Dead Mode’

Defines, Groups. Let’s put on some variables on main functions with ()

if age_group == 'Starter ':

I forgot to mention that I’m using not script to launch and check things in the mini console, but for debugging I use Atom-Python-Run package

Run this experiment …

In a terminal in your Ubuntu run the command


You will see an output like this …

Python 2.7.12 (default, Nov 12 2018, 14:36:49) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Now after the >>> prompt try one of your print statements …

>>>print(“Welcome to Royal AK-47 SHOP”)

You will see this error …

  File "<stdin>", line 1
    print(“Welcome to Royal AK-47 SHOP”)
SyntaxError: invalid syntax

Conclusion: Your syntax is for python 3 and not python 2.
Install python 3 and ensure that you have python 3 in shebang at top of your code.

1 Like

It’s very common to have multiple versions of Python installed, so you have a number of options for how to manage them.

  1. Shebangs will guarantee that your code always goes to the right place, but if you have a codebase that doesn’t have them already, it can be annoying to have to add them to each of the files you might want to run.

  2. There’s a program for Unix-based computers called pyenv that allows you to install as many versions as you want and swap between them pretty seamlessly.

  3. You can do manually what pyenv does for you, and rewrite your PATH variable so that the Python 3.7 comes first. Your computer will go with the first python executable it finds.