Questions tagged [python]

Python is an interpreted, general, high-level programming language. Programming questions are off topic. Questions about the use of Python should be asked at Stack Overflow (https://www.stackoverflow.com) instead.

About

Wikipedia has much more: http://en.wikipedia.org/wiki/Python_(programming_language)

The official website is here: http://www.python.org/

Python's direction and language development is still controlled by its original author, Guido van Rossum. Guido is now an employee of Google, which uses Python exclusively as its glue/scripting language. He is affectionately known as the language's 'benevolent dictator'.

As of Spring 2011, there are two major development branches of Python: 2.x and 3.x (Python 3000). Python 3000 was released with many breaking syntactic changes as a result of efforts to promote consistency in the language and to fully integrate Unicode support. This has led to slow adoption of the new version, as many people are dependent on the extensive libraries available in Python and many libraries have not been upgraded to support Python 3.

Tag usage

Use for questions about computer hardware or software related to Python. Do not ask programming questions as they are off-topic here. Ask them on Stack Overflow instead.

3206 questions
244
votes
3 answers

Why are tar.xz files 15x smaller when using Python's tar library compared to macOS tar?

Context I'm compressing ~1.3 GB folders each filled with 1440 JSON files and find that there's a 15-fold difference between using the tar command and Python's built-in tarfile library on macOS or Raspbian 10 (Buster) Minimal working example This…
228
votes
8 answers

Typing “python” on Windows 10 (version 1903) command prompt opens Microsoft store

This is strange issue I have observed. I installed Active Python 2.7 on Windows 10 (version 1903). On typing “python” from search, opens the Python 2.7 prompt but when I type from command prompt window, it triggers the Microsoft Store. Don't know…
Dr. Essen
  • 2,552
206
votes
8 answers

Find outdated/updatable pip packages

pip freeze shows me the packages installed, but how do I check against pypi which ones are outdated?
Xster
  • 3,025
110
votes
5 answers

How do I add Python to the Windows PATH?

I want to be able to run Python commands from the Windows CMD. However, if I don't specify Python's full path for each command, I get an error saying "Python is not recognized as an internal or external command, operable program or batch file." How…
davewise
  • 1,203
105
votes
12 answers

How to update Python on Ubuntu system?

I want to update the Python build on my Linux box, but the only way I know how to do it is uninstalling the current version and installing the new one. My system is already up to date (I updated yesterday). I wanted to know if there is a way to…
73
votes
4 answers

python3-pip installed but pip3 command not found?

I am testing a Python3 program in several computers. To do that, I need to install a library of Python with pip3. So first, I was installing python3-pip in each computer (everyone is running Kubuntu OS). Everything was OK, and then I installed the…
forvas
  • 903
71
votes
8 answers

emacs: how to indent/unindent region of python code by 4 spaces?

I have a region of python code selected in emacs. What are the most efficient ways to indent and unindent every line in it by 4 spaces? Ideally I'd like something that's not context sensitive (eg. it'll allow me to indent passages within docstrings…
70
votes
2 answers

macOS, the command line developer tool missing after updated to Monterey 12.6

My Apple MacBook pro M1 2020 automatically updated to Monterey 12.6 recently. With the update, I have to agree with an Xcode agreement/license. After that, I found both python and git are no longer working properly. I got a pop-up saying: The “git”…
r0ng
  • 855
67
votes
7 answers

Can't install virtual interpreter in PyCharm in Linux

When I try to add virtualenv as an interpreter in PyCharm Community 2018.1.2 in Kubuntu 18.04 I get the following error: ModuleNotFoundError: No module named 'distutils.core' How can I solve this?
Hrvoje T
  • 1,959
61
votes
5 answers

How do you install git-filter-repo?

I'm attempting to use git-filter-repo to remove large binaries from my repository. I have not used python before. I installed the latest python by clicking on the downloaded .exe file as that is a requirement of git-filter-repo. The instructions…
CBFT
  • 833
53
votes
1 answer

What does "precompile standard library" option mean in python installation?

I am trying to understand different options in Python3 installation. What does the "Precompile Standard library" option mean in the Custom Python installation and why should it be enabled or left deselected by default?
GP92
  • 309
52
votes
5 answers

Run Python scripts without explicitly invoking `python`

I'm using Debian Linux. I was wondering if there was a way to configure to run all Python scripts in the terminal by typing script.py (instead of python script.py).
user2018084
  • 2,254
49
votes
10 answers

Why doesn’t Shift+Enter send code to Python interactive in VS Code?

I'm currently setting up a Python development environment with Anaconda and VS Code. On my old laptop, I could run python code by pressing Shift+Enter and VS Code would send it to the Python Interactive window. When I do this now, the code gets sent…
Julian
  • 593
44
votes
9 answers

How do I write code of more than 1 line in the Python interpreter?

I have a problem coding Python in terminal. I'm just learning basics so I have no need to create .py files. In terminal I can run one line of code in the Python interpreter, but how do I write more than one line? Obviously if I hit enter, it enters…
user98645
44
votes
5 answers

Docker / GCloud | How to fix docker-credential-gcloud not installed or not available in PATH?

I am trying to do a simple docker-compose command. But the console errors with that: Building patch-panel Traceback (most recent call last): File "bin/docker-compose", line 6, in File "compose/cli/main.py", line 71, in main File…
1
2 3
99 100