433
votes
Change the Python3 default version in Ubuntu
From the comment:
sudo update-alternatives --config python
Will show you an error:
update-alternatives: error: no alternatives for python3
You need to update your update-alternatives , then you ...
166
votes
zipimport.ZipImportError: can't decompress data; zlib not available
Ubuntu 16.10+ and Python 3.7 dev
sudo apt-get install zlib1g-dev
Note: I only put this here because it was the top search result for the error, but this resolved my issue.
Update: also the case for ...
74
votes
Change the Python3 default version in Ubuntu
You can achieve this by applying below simple steps -
Check python version on terminal: python --version
Execute this command to switch to python 3.6:
sudo update-alternatives --install /usr/bin/...
56
votes
Is there something wrong with my script or is Bash much slower than Python?
Shell loops are slow and bash's are the slowest.
Shells aren't meant to do heavy work in loops. Shells are meant to launch a few external, optimized processes on batches of data.
Anyway, I was ...
51
votes
Accepted
How to run a command inside a virtualenv using systemd
This doesn't work because source is a shell command, so systemd's ExecStart= or ExecStartPre= won't understand them directly... (BTW, the same is true for cd and the &&.)
You could achieve ...
46
votes
Change the Python3 default version in Ubuntu
if you have multiple version of python in your system. You just need to update the symbolic link of python inside /usr/bin/
root@irshad:/usr/bin# ls -lrth python*
lrwxrwxrwx 1 root root 9 Apr 16 ...
41
votes
Accepted
How to make python3.7 default
Simple solution is edit .bashrc and put this line:
alias python3=python3.7
Whenever you will write python3 it will replace it with python3.7.
Or you can use command update-alternatives which is ...
36
votes
gcc error installing psycopg2 package for python3 on Centos 7.3
For Ubuntu use
sudo apt install libpq-dev
31
votes
"ModuleNotFoundError: No module named 'apt_pkg'" appears in various commands
Original answer from https://askubuntu.com/q/1242009/747557, credit to @Hmdbbgh.
The solution that worked for me was to reinstall python3-apt:
sudo apt remove python3-apt
sudo apt autoremove
sudo apt ...
27
votes
Change the Python3 default version in Ubuntu
Using these commands can help you:
check the version of python:
ls /usr/bin/python*
alias:
alias python='/usr/bin/pythonxx' (add this to . ~/.bashrc)
re-login or source . ~/.bashrc
check the python ...
23
votes
Accepted
How to make `python` an alias of `python3` systemwide on Debian
It looks like Debian is now shipping python-is-python3 themselves (in Debian 11 and later), so the premise of the question no longer holds and you can just: sudo apt update && sudo apt install ...
22
votes
Accepted
Difference between installing a package with 'apt' and 'pip'
I will appreciate if someone could explain the differences (if any) between:
Highest level: you never should use pip install to install to system (--system, or on Linux distros where --user isn't the ...
21
votes
Accepted
Is there something wrong with my script or is Bash much slower than Python?
This is a known bug in bash; see the man page and search for "BUGS":
BUGS
It's too big and too slow.
;)
For an excellent primer on the conceptual differences between shell scripting and ...
18
votes
Is there something wrong with my script or is Bash much slower than Python?
I did a bit of testing, and on my system ran the following--none made the order of magnitude speedup that would be needed to be competitive, but you can make it faster:
Test 1: 18.233s
#!/bin/bash
...
16
votes
Accepted
cron job to run under conda virtual environment
Posted a working solution (on Ubuntu 18.04) with detailed reasoning on SO.
The short form is:
1. Copy snippet appended by Anaconda in ~/.bashrc (at the end of the file) to a separate file ~/....
16
votes
Accepted
How to downgrade python version in Ubuntu 20.04?
Do not downgrade the system version: it's likely that some parts of the system would stop working. Never change /usr/bin/python3, and avoid putting an older version of python3 before it in the $PATH.
...
16
votes
Accepted
If I have two versions of python3 installed on my machine (ie: 3.11.2 and 3.12), how do I set the default version to use when running python scripts?
Since you’re using env python3, the default version of Python will be determined by whichever version of python3 is first in the PATH variable. You can thus choose which version is used by ...
14
votes
Change the Python3 default version in Ubuntu
First check that you have a python3.6 folder?
ls /usr/bin/python3.6
If you have "python3.6" folder, you are good to go. Now update-alternatives
sudo update-alternatives --install /usr/bin/...
14
votes
Accepted
Changing Python's default version breaks Ubuntu 20.04
As you discovered, the system does rely on the system version of Python being as it expects. If you really want a system with Python 3.6, your best bet is to find a (ideally, still supported) release ...
13
votes
gcc error installing psycopg2 package for python3 on Centos 7.3
I was missing libpq-fe.h, which I obtained by installing postgresql-devel
sudo yum install postgresql-devel
11
votes
Is there something wrong with my script or is Bash much slower than Python?
A shell is efficient if you use it for what it has been designed for (though efficiency is rarely what you look for in a shell).
A shell is a command-line interpreter, it is designed to run commands ...
11
votes
Accepted
The python command starts the the wrong version of the python interpreter
It's very likely that the python command has been hashed and that you need to clear the cache. In order to see what executable is actually being run you can use the type command, e.g.:
type -a python
...
11
votes
pip hangs on `Loading macOS` when installing a package
I had the same problem, after messing with PyPi credentials. The following fixed it for me.
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
See: https://github.com/pypa/pip/issues/7883
11
votes
How to downgrade python version in Ubuntu 20.04?
Alternatively, you can create a virtual environment.
Suppose you have python 3.8 (or higher) installed on the system, but for a specific task, you need python 3.7 (or lower). The best idea is (not to ...
10
votes
When I use ansible module expect, I get this msg: The pexpect python module is required
As is typical with some of the modules in ansible you have to install certain Python modules on the remote server's side.
https://github.com/ansible/ansible/issues/21416
You can use the pip module ...
slm♦
- 374k
10
votes
Accepted
CentOS python3 package difference between python36 and python36u
python36u is an alternative build provided by IUS; python36 is an EPEL package.
yum info python36 python36u will show you different repos for the two, and it's likely that the IUS one has a slightly ...
10
votes
If I have two versions of python3 installed on my machine (ie: 3.11.2 and 3.12), how do I set the default version to use when running python scripts?
To complement @StephenKitt's fine answer, on Debian-based systems, you may be able to install packages for more than one version of python concurrently. For instance here on Ubuntu 22.04, I have 3.10 ...
10
votes
If I have two versions of python3 installed on my machine (ie: 3.11.2 and 3.12), how do I set the default version to use when running python scripts?
I know this questions only asks about the apt package manager, and the other answers cover that aspect very well.
But if you are working with several different python projects, all requiring different ...
9
votes
Accepted
Enabling python3 on vim in Fedora 24
The issue is that simply executing has('python') in an if-statement causes python3 to be unavailable when vim was compiled with both python/dyn and python3/dyn. The simplest solution is probably just ...
9
votes
zipimport.ZipImportError: can't decompress data; zlib not available
Simply copy paste this code:
CFLAGS="-I$(brew --prefix readline)/include -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" \
LDFLAGS="-L$(brew --prefix readline)/lib -L$(brew ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
python3 × 396python × 152
ubuntu × 51
linux × 42
debian × 42
pip × 36
centos × 28
software-installation × 26
bash × 18
shell-script × 17
linux-mint × 15
kali-linux × 15
rhel × 14
apt × 14
raspberry-pi × 14
virtualenv × 12
fedora × 9
systemd × 9
cron × 9
package-management × 8
arch-linux × 7
raspbian × 7
shell × 6
ssh × 6
yum × 6