How To Run Python In Ubuntu (Linux)?

Wajiha Urooj
Edureka
Published in
4 min readSep 6, 2019

This article will introduce a very simple yet interesting and important concept that is How To Run Python In Ubuntu (Linux)? with a detailed practical demonstration. So let us get started then,

How to run Python in Ubuntu (Linux)

If you are curious about how to run Python in Ubuntu, here’s an article dedicated to it that may help you out. We are here using Ubuntu Version 14.04. It supports Python 2 and Python 3 versions.

So here is the first step.

Step1: Open your desktop like this.

Step2: Go for Files > Documents on the left-hand side.

Step3: In documents, you can either go for a folder in which you want to save your program or directly make a program there itself.

Step 4: Right-click in that area and select a New Document > Empty document.

Step 5: Name your file with a .py extension so that the system can detect it is a python file.

Step 6: Open your file and you’ll find out the file opens in ‘gedit’.

Write down your desired program in the given area and save it.

Step 7: Open Terminal in left-hand side down corner.

Step 8: Once done, we have to change the directory so that it’s easy to access for us to fetch the code.

Step 9: For that, the Linux command is cd Documents/ wherever your file is saved.

Step 10: Once done, enter and you are in that particular directory.

Step 11: Now to run your Python file, all you have to command is ‘ python yourfilename.py’.

Step 12: It basically tells the terminal to run the python file.

Step 13: In case if you want to check which version of Python are you using, you can write the python -version.

Step 14: Instead of using the Python 2 version, if you use Python 3 version, you can readily execute it by writing ‘python3 yourfilename.py’.

Step 15: Make sure while executing your Python code in Python 3 version, you use the syntax according to Python 3. Example: Python 2 print statement may or may not have ( ) with print statements but in Python 3, print statements should be with ().

I hope that you learned the concepts well and hence try it out to be more accurate. Does this bring us to the end of this article on How To Run Python In Ubuntu (Linux)? If you wish to check out more articles on the market’s most trending technologies like Artificial Intelligence, DevOps, Ethical Hacking, then you can refer to Edureka’s official site.

Do look out for other articles in this series that will explain the various other aspects of Python and Data Science.

1. Machine Learning Classifier in Python

2. Python Scikit-Learn Cheat Sheet

3. Machine Learning Tools

4. Python Libraries For Data Science And Machine Learning

5. Chatbot In Python

6. Python Collections

7. Python Modules

8. Python developer Skills

9. OOPs Interview Questions and Answers

10. Resume For A Python Developer

11. Exploratory Data Analysis In Python

12. Snake Game With Python’s Turtle Module

13. Python Developer Salary

14. Principal Component Analysis

15. Python vs C++

16. Scrapy Tutorial

17. Python SciPy

18. Least Squares Regression Method

19. Jupyter Notebook Cheat Sheet

20. Python Basics

21. Python Pattern Programs

22. Web Scraping With Python

23. Python Decorator

24. Python Spyder IDE

25. Mobile Applications Using Kivy In Python

26. Top 10 Best Books To Learn & Practice Python

27. Robot Framework With Python

28. Snake Game in Python using PyGame

29. Django Interview Questions and Answers

30. Top 10 Python Applications

31. Hash Tables and Hashmaps in Python

32. Python 3.8

33. Support Vector Machine

34. Python Tutorial

Originally published at https://www.edureka.co on September 6, 2019.

--

--