Questions tagged [python]

Python is an interpreted programming language that is often, but not solely, used as a scripting language. A version of Python is included by default on all Ubuntu distributions.

Python is a general purpose language which can be used for anything from quick scripting jobs to fully object-oriented GUI programs.

Python is designed to have readable source code. As such, code blocks are delimited by indentation instead of the braces used in many other languages. Python is one of few programming languages to have significant white space.

Unlike C-like languages, Python is generally not compiled and is instead an interpreted language. The most common interpreter is CPython, which is written in C. Other interpreters are PyPy, which is written in Python and Jython, which is written in Java.

From http://hg.python.org/peps/rev/76d43e52d978 (PEP 373, Python 2.7 Release Schedule):

The End Of Life date (EOL, sunset date) for Python 2.7 has been moved five years into the future, to 2020. This decision was made to clarify the status of Python 2.7 and relieve worries for those users who cannot yet migrate to Python 3.

5257 questions
735
votes
8 answers

How to make 'python' program command execute Python 3?

The python program command executes Python 2. Python 3 can be executed using the python3 command. How can Python 3 be executed using the python command?
Cloud Engineer
  • 7,493
  • 3
  • 14
  • 9
256
votes
12 answers

How do I install a different Python version using apt-get?

How can I install a different version of Python using apt-get? Obviously I realise I can install using the source tar ball, however I would prefer not to install from source and instead use the package manager, as that's what it's there for. Surely…
AgileZebra
  • 2,663
219
votes
19 answers

ModuleNotFoundError: No module named 'distutils.util'

After updating to Ubuntu 20.04, whenever I run: pip install or pip --version it says: adam@daryy:~$ pip3 Traceback (most recent call last): File "/usr/local/bin/pip3", line 5, in from pip._internal.cli.main import…
Rock Life
  • 2,290
188
votes
6 answers

How do I install the latest Python 2.7.X or 3.X on Ubuntu?

I want to install the latest Python tarball on Ubuntu, downloaded from http://python.org/download/. Is this is a correct way to install? ./configure make make install If not, how do I do that?
mohammads
  • 2,654
175
votes
2 answers

Installing python: who is deadsnakes and why should I trust them?

I want to install Python 3.9 on my Ubuntu 20.04, and all tutorials I can find include a step as follows: sudo add-apt-repository ppa:deadsnakes/ppa I am concerned about security. I've looked into this question: Are PPAs safe to add to my system and…
Pedro A
  • 1,963
163
votes
8 answers

Pip is not working: ImportError: No module named 'pip._internal'

Running pip or pip3 results with: Traceback (most recent call last): File "/home/myuser/.local/bin/pip", line 7, in from pip._internal import main ImportError: No module named 'pip._internal' I had issues with this, and uninstalled pip3,…
Keweik
  • 1,731
136
votes
4 answers

apt-get install vs pip install

I am a bit confused about the cases in which the above commands must be used when downloading python packages. I was trying to download a package named pyudev in accordance with an answer with this question. I executed this command : sudo pip…
127
votes
15 answers

How do I check whether a module is installed in Python, and install it if needed?

In terminal, after I start Python, how will I know what are the modules present in python? Suppose I need to learn the modules NumPy and SciPy. How will I install it if it is not installed? How will I know if it is already installed?
sigdelsanjog
  • 7,280
126
votes
3 answers

installing pip3 (for python3) on ubuntu 16.04 LTS using a proxy

I have tried entering: sudo apt install python3-pip The error I get is: $ sudo apt install python3-pip Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be…
Abisdad
  • 1,361
126
votes
6 answers

How do I sudo a command in a script without being asked for a password?

I want to turn my system on automatically every day. So I use the below code in my Python script, but sudo asks me for a password every time: os.system('sudo sh -c "echo date \'+%s\' -d \'+ \ 24 hours\' > /sys/class/rtc/rtc0/wakealarm"') How…
Viswa
  • 1,679
118
votes
6 answers

How to install geckodriver in Ubuntu?

I use Selenium in Python, I tried to run the webdriver function: default_browser = webdriver.Firefox() This Exception: WebDriverException: Message: 'geckodriver' executable needs to be in PATH. geckodriver in this site:…
mySun
  • 2,021
118
votes
3 answers

How to add a Python module to syspath?

I have a file structure like this: Folder Common foo1.py TestFolder foo2.py I want to import in foo2.py and foo1.py. I tried but it doesn't work on Ubuntu: sys.path.append(os.path.abspath('../../')) from Common import foo1.py
user284474
  • 1,181
116
votes
11 answers

How to install Anaconda on Ubuntu?

How to install Anaconda for Python on Ubuntu? Is there a way to use apt-get install? I only have command line access to my server. How do I install Anaconda on Ubuntu 14.04 from the command line?
alvas
  • 3,027
116
votes
2 answers

python-is-python3 package in Ubuntu 20.04 - what is it and what does it actually do?

Having used Ubuntu 18.04 for a handful of years now, and reading that Python 2 has been removed from Ubuntu 20.04, I was looking forward to using the commands python or pip rather than python3 or pip3. So today I tried Ubuntu 20.04 for the first…
cdahms
  • 1,993
110
votes
9 answers

Is there a GUI designer for Python?

Is there a GUI IDE for programming Python just like Java has NetBeans? I wanted one where we could drag & drop test boxes & labels just as we do with Swing components using NetBeans or Eclipse. Or is there an add-on present in either NetBeans or…
Roshan
  • 1,203
1
2 3
99 100