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.

3117 questions
243
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…
Saaru Lindestøkke
  • 5,515
  • 8
  • 30
  • 48
223
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,502
  • 3
  • 11
  • 14
190
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
  • 2,845
  • 5
  • 24
  • 19
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
  • 2
  • 9
  • 5
103
votes
10 answers

Updating 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…
efficiencyIsBliss
  • 2,289
  • 4
  • 20
  • 14
71
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
  • 883
  • 1
  • 7
  • 16
68
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
  • 825
  • 2
  • 7
  • 12
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,949
  • 3
  • 18
  • 28
65
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…
Ian Mackinnon
  • 5,606
  • 5
  • 29
  • 33
52
votes
4 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
  • 733
  • 1
  • 5
  • 9
50
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,064
  • 9
  • 38
  • 50
47
votes
1 answer

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

I am trying to understand different options in python 3.6 installation. What does the Precompile Stadard library means in the Custom Python installation and why it could be deselected by default?
GP92
  • 697
  • 2
  • 7
  • 12
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…
43
votes
8 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
39
votes
1 answer

Accidentally deleted log file of running process `python something.py 2>&1 | tee .log`. Is there a way to still save the output on the tmux-pane?

Accidentally deleted log file of running process python something.py 2>&1 | tee .log. The script is running in a tmux pane on zsh. The process is still running but not logging. The output itself overflows the tmux-scrollback-buffer. Can I somehow…
baxbear
  • 516
  • 5
  • 10
1
2 3
99 100