I want to install Python 3.10 on Ubuntu 18.04 (I'm currently on Python 3.8) from the deadsnakes repository with the following set of commands I found on the internet:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.10
But I got the error sudo: add-apt-repository: command not found.
More net research led me to this set of commands at "ModuleNotFoundError: No module named 'apt_pkg'" appears in various commands - Ask Ubuntu:
sudo apt remove python3-apt
sudo apt autoremove
sudo apt autoclean
sudo apt install python3-apt
Other web sources said the same thing, so I did that, but I still get the error message when I run sudo add-apt-repository ppa:deadsnakes/ppa.
Then I found How to Fix 'add-apt-repository command not found' on Ubuntu & Debian - phoenixNAP, which advised this set of commands:
sudo apt update
sudo apt install software-properties-common
sudo apt update
so I did that, but when I run sudo add-apt-repository ppa:deadsnakes/ppa I now get this error message:
~$ sudo add-apt-repository ppa:deadsnakes/ppa
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 12, in <module>
from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 28, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
I have found some web links that show a wide variety of solutions with earlier versions of Python. I'm currently on Python 3.8.
Before I do anything more I want to ask what is the best way to solve the ModuleNotFoundError: No module named 'apt_pkg' error message when trying to install the deadsnakes repository to install Python 3.10, given the number of possible solutions I have seen.
Thanks very much.
This worked for me:
sudo apt-get install python3-apt --reinstall
cd /usr/lib/python3/dist-packages
sudo cp apt_pkg.cpython-38-x86_64-linux-gnu.so apt_pkg.so
The 38 in the filename above can be different for you.
Related
I need to update the default python version in Google Colab to version 3.9 in order to install some packages via poetry. However, when I update python I seem to lose the ability to install anything at all. I'm updating python by following the accepted answer here, which works in so far as giving me the version of python I need:
#install python 3.9
!sudo apt-get update -y
!sudo apt-get install python3.9
#change alternatives
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
#check python version
!python --version
# returns Python 3.9.13
However, when I then try to install poetry via !pip3 install poetry I get the following response:
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'
Curiously, when I try !pip3 install poetry before updating python it works. However, if I install poetry first, then update python, when I try to install the variopus packages I need via !poetry install I get a similar traceback error:
Traceback (most recent call last):
File "/usr/local/bin/poetry", line 5, in <module>
from poetry.console import main
ModuleNotFoundError: No module named 'poetry'
Long-story-short, I can't work out how I can get the version 3.9 of python in Colab AND poetry to work.
Yes you need to install pip with !sudo apt-get install python-pip
Then you might need the distutils lib !sudo apt install python3.9-distutils
I have python 3.5.3
I m trying to upgrade to python 3.7.2
I used the cammand bellow :
sudo apt install python3.7.2
I got the following message
E: Unable to locate package python3.7.2
E: Couldn't find any package by glob 'python3.7.2'
E: Couldn't find any package by regex 'python3.7.2'
I used the command below to fix it
sudo apt-get install software-properties-common
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get install python3.7.2
and I till have the same problem
I found this in the Internet by searching your first error message.
Hello,
Have you tried running python3.7 --version instead of only python3?
If this still does not work what I would suggest is following these steps here:
Run a quick update and install the following package:
apt update
sudo apt install software-properties-common
Add the following to your source list:
sudo add-apt-repository ppa:deadsnakes/ppa
Note: In case that you get prompted just press Enter to continue
After that install Python 3.7 with the command that you’ve specified in your question:
sudo apt install python3.7
Then again test this with:
python3.7 --version
Hope that this helps!
https://www.digitalocean.com/community/questions/unable-to-install-pyhton-3-7-version-on-ubuntu-16-04-error-couldn-t-find-any-package-by-regex-python3-7
i use this little script from https://stackoverflow.com/a/63396200/2891692
in the new installed Ubuntu i installed python3-autopilot again (sudo apt-get install python3-autopilot).
seems i have the newest version:
python3-autopilot is already the newest version (1.6.0+17.04.20170313-0ubuntu8).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
but my python script here
from autopilot.input import Mouse
gives to following error:
Script name: 'autopilot-test'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/autokey/service.py", line 485, in execute
exec(script.code, scope)
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'autopilot.input'
i tried proposals for this problem from https://askubuntu.com/a/316103/1017209
but they dont't work for me, as you could see below:
1.
sudo apt-add-repository ppa:autopilot/ppa
sudo apt-get update
sudo apt-get install libautopilot-qt python-autopilot
Package libautopilot-qt is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'libautopilot-qt' has no installation candidate
E: Unable to locate package python-autopilot
dpkg -l python-autopilot
dpkg-query: no packages found matching python-autopilot
first test it i new Kubuntu then try reinstall al python stuff
as test i installed Kubuntu on other HDD (today (2021-02-28) and my mouse-autopilot-test.py works like expected.
then (2021-02-28) i tried repair my working OS like so (without success) :
uninstall python3 - both configuration and data files of python3.x and it's dependencies (takes some minute):
sudo apt-get purge --auto-remove python3.*
try reinstall my most used pyton
sudo apt install --reinstall python3-pkg-resources python3-setuptools
sudo apt-get install autokey-qt
sudo apt-get install python3-autopilot
error when running mouse-autopilot-test.py :
ModuleNotFoundError: No module named 'autopilot.input'
what could i do to fix that?
I am trying to run an Arducam MT9J001 camera on a raspberry pi 3b+. I am getting the following error when I try to run the program, "ImportError: libcblas.so3: cannot open shared object file: No such file or directory." I have the computer vision software downloaded onto the raspberry pi, though it seems that it is still not working. I'm not sure what other information is viable to this project, but if there is something else I should be specifying please let me know.
What worked for me (I was missing some dependencies):
pip3 install opencv-python
sudo apt-get install libcblas-dev
sudo apt-get install libhdf5-dev
sudo apt-get install libhdf5-serial-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev
sudo apt-get install libqtgui4
sudo apt-get install libqt4-test
You need to install only one package with neccessary shared object for it to work
sudo apt-get install libatlas-base-dev
Exact same solution as #thvs86 but here's a single 1 line copy-paste so you don't have to insert each command individually:
pip3 install opencv-contrib-python; sudo apt-get install -y libatlas-base-dev libhdf5-dev libhdf5-serial-dev libatlas-base-dev libjasper-dev libqtgui4 libqt4-test
I installed python3 and pip3 successfully on my Ubuntu16.04, but pip3 install is broken. How can I fix this problem? The error info of pip3 install is as follows:
# pip3 install xlwt
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
ModuleNotFoundError: No module named 'pip._vendor.requests'
Output of "which pip3" and "pip3 --version":
# which pip3
/usr/bin/pip3
# pip3 --version
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
ModuleNotFoundError: No module named 'pip._vendor.requests'
p.s. Python2 pip runs successfully.
Output of "which pip" and "pip --version":
# which pip
/usr/bin/pip
# pip --version
pip 1.5.4 from /usr/local/lib/python2.7/dist-packages/pip-1.5.4-py2.7.egg (python 2.7)
And python and python3 installation information:
# which python
/usr/bin/python
# which python3
/usr/bin/python3
# python -V
Python 2.7.14
# python3 -V
Python 3.6.3
Any solution or clue will be appreciated! Thank you!
Here, trying this method: https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py
# sudo python3 get-pip.py
This has happened to me multiple times before. A lot of the time, pip3 has issues installing with python3 by default, so try uninstalling and reinstalling pip3. Hope this works.
sudo apt-get remove python3-pip; sudo apt-get install python3-pip
EDIT:
After doing some scouting about pip.vendor.requests, it seems like this is a very common error relating to SSL problems. If this line gives you errors in python (import ssl), some solutions can be found here:
https://github.com/pypa/pip/issues/2345.
This worked for me.
First remove your python3-pip:
sudo apt remove python3-pip
Then do this:
sudo apt install --purge python3-setuptools
And finally:
sudo apt install python3-pip
python-pip is in the universe repositories, therefore use the steps below to solve Python3 pip3 broken problem on Ubuntu. Also works for Ubuntu available from official store in windows 10 for WSL (windows subsystem for linux):
sudo apt-get install software-properties-common
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get -y install python3-pip
I got help from here - [https://askubuntu.com/a/672836/876942]. Following these steps installs python 2. But then I installed python 3 using [sudo apt-get -y install python3-pip] in last step.