I'm on Ubuntu 16.04, and I get:
Traceback (most recent call last):
File "/home/omermazig/.virtualenvs/fixi/bin/pip", line 7, in <module>
from pip import main
File "/home/omermazig/.virtualenvs/fixi/lib/python3.6/site-packages/pip/__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/home/omermazig/.virtualenvs/fixi/lib/python3.6/site-packages/pip/utils/__init__.py", line 23, in <module>
from pip.locations import (
File "/home/omermazig/.virtualenvs/fixi/lib/python3.6/site-packages/pip/locations.py", line 9, in <module>
from distutils import sysconfig
File "/home/omermazig/.virtualenvs/fixi/lib/python3.6/distutils/__init__.py", line 25, in <module>
from distutils import dist, sysconfig
ImportError: cannot import name 'dist'
When I run anything with python. This specifically is for trying to run "pip freeze". What to do?
try it
sudo apt install python3-distutils
My case was when I upgraded Ubuntu 18 -> 19.
So it reinstalled python and what I needed to do is:
remove old virtual environment
create a new one
install requirements via pip into it
I ran into this problem after installing Python 3.8 on Ubuntu (I have version 16.04)
$ lsb_release -d
Description: Ubuntu 16.04.6 LTS
Reproduce the error
Just try to import distutils
$ python3 -c "from distutils import sysconfig"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py)
$ sudo apt install python3-distutils
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python3-distutils
The package python3-distutils cannot be found
$ sudo apt install python3-distutils
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python3-distutils
list available distutils
What helped was to list all distutil packages using a regexp
$ apt list *distutils*
Listing... Done
python-distutils-extra/xenial,xenial 2.39-1 all
python-stsci.distutils/xenial,xenial 0.3.7-4 all
python3-distutils-extra/xenial,xenial 2.39-1 all
python3-stsci.distutils/xenial,xenial 0.3.7-4 all
python3.7-distutils/xenial,xenial 3.7.8-1+xenial1 all
python3.8-distutils/xenial,xenial 3.8.3-1+xenial1 all
python3.9-distutils/xenial,xenial 3.9.0~b4-1+xenial1 all
Install the correct distutils package
For my Python 3.8 I picked python3.8-distutils and it worked
$ sudo apt-get install -y python3.8-distutils
Since I run into this issue everytime I update my ubuntu version every six months, then stumble on the exact same SO result, here is my solution.
If the other solutions listed here don't work (installing python3-distutils), it might be because of different python versions between the system and the virtualenv.
The easy solution is to destroy your virtualenv, then recreate it from scratch.
Solved: I've just got this issue in a virtual environment installed 2 years ago, using python3.7
Running pip3 or python3.7 -c "from distutils import dist, sysconfig" from the venv, I got the error ImportError: cannot import name 'dist'
Using system python 3.9, this error disappers.
I solved copying the /usr/lib/python3.9/distutils into the python3.7 virtual environment.
Take a loot at this (similar problem):
https://github.com/pypa/pip/issues/5367
Possible fix:
Download Python source from https://www.python.org/
Decompress the source code
Install the following dependencies:
sudo apt-get install zlib1g-dev (needed to compile Python)
and install:
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev (needed by Pip to make SSL requests)
Compile and install Python:
/configure
make
make install
Python 3.6 with Pip should be installed.
Full credit to jonbesga.
Related
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'm trying to install the module aiohttp for python so I can set up a system for downloading files with uvloop. I'm having some difficulty, though, when I go into my folder which I extracted aiohttp to and doing the following commands:
sudo python3 setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from setuptools import setup, Extension
ImportError: No module named 'setuptools'
I looked around and saw that some people had this problem but it was fixed by getting the python-setuptools or python3-setuptools package. So I tried to do that but this is the output I get:
$ sudo apt-get install python3-setuptools
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-setuptools is already the newest version.
python3-setuptools set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
$ sudo apt-get install python-setuptools
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-setuptools is already the newest version.
python-setuptools set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
Which leads me to believe that python-setuptools is already installed! I'm not sure where to go from here. Just for clarity, I did try
sudo python setup.py install
but I received an error because Python 3.4.1+ is needed to install aiohttp:
sudo python setup.py install
Traceback (most recent call last):
File "setup.py", line 61, in <module>
raise RuntimeError("aiohttp requires Python 3.4.1+")
RuntimeError: aiohttp requires Python 3.4.1+
I'm running Linux Mint 17.2 Qiana on an HP Elitebook 8440p. Any suggestions as to what I should do?
Thanks in advance!
First Install python3
brew install python3 && cp /usr/local/bin/python3 /usr/local/bin/python
Then use pip3 to install aiohttp
pip3 install aiohttp
sudo dnf install python-devel-2.7.12-6.fc24.x86_64 solved my problem
For me installing uvloop worked, working on Mac laptop:
pip install uvloop
I'm getting this error when trying to install any package with pip. I have two pip instances, one with Python 2.7 and other with Python 3.
Could not import setuptools which is required to install from a source distribution.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 375, in setup_py
import setuptools # noqa
File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 11, in <module>
from setuptools.extern.six.moves import filterfalse, map
File "/usr/local/lib/python2.7/dist-packages/setuptools/extern/__init__.py", line 1, in <module>
from pkg_resources.extern import VendorImporter
ImportError: No module named extern
Even when I try to install the 'extern' module I get this error. Also when installing with Python itself, like python setup.py install.
Thanks in advance.
sudo apt-get purge python-pkg-resources
sudo apt-get -f install
here actually packages are removed and
purged (any configuration files are deleted too).
-f : Attempt to correct a system with broken dependencies in place.
sudo pip install packagename
#sourcehere
Do this it will work
sudo pip install -U setuptools
I know this is an old thread, but I just wanted to contribute since I ran into this issue and this thread kept coming up in the results.
Note: This was on MacOS 10.12. My shell is zsh and I already have brew installed
First I ran each of these commands
brew install python
brew install python3
This will either install it or you'll receive an "already installed" message as I did.
Next, run the following command
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
And last:
sudo python get-pip.py
Final note: for my install to work, I ended up having to run the command with pip3
sudo pip3 install nameofinstallhere
Not sure whether it is installation issue or packege but it seems like you will not be able to import any package of them, if you have installed python perfectly then
try this commands
step 1 :
$which pip
/usr/local/bin/pip
step 2 :
/usr/local/bin/pip install django
or any of your package name.
I am considering ubuntu(OS)
You can try the following command; it has worked for me:
sudo apt-get install --reinstall python-setuptools
My Ubuntu 10.04 came with Python 2.6. Now, I also installed Python 2.7, which is the system default now because when I start python from the terminal, it starts python 2.7.
Now, I want to install the library pysftp using pip, but I'm having a hard time doing so. Below follow some results of my attempts and conclusions. I did pip install pysftp, but it says the following:
Downloading/unpacking pysftp
Running setup.py egg_info for package pysftp
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/usr/local/lib/python2.6/dist-packages/setuptools/__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "/usr/local/lib/python2.6/dist-packages/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/usr/local/lib/python2.6/dist-packages/setuptools/dist.py", line 21, in <module>
packaging = pkg_resources.packaging
AttributeError: 'module' object has no attribute 'packaging'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/usr/local/lib/python2.6/dist-packages/setuptools/__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "/usr/local/lib/python2.6/dist-packages/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/usr/local/lib/python2.6/dist-packages/setuptools/dist.py", line 21, in <module>
packaging = pkg_resources.packaging
AttributeError: 'module' object has no attribute 'packaging'
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in ./pip-log.txt
It seems to me that pip (which was obviously installed before Python 2.7 was installed) links to the old version of Python, which doesn't support pysftp. Also because when I do pip --version it says:
pip 0.3.1 from /usr/lib/python2.6/dist-packages (python 2.6)
When I do whereis python, it gives me the following information:
python: /usr/src/Python-2.7.10/python /usr/bin/python2.6 /usr/bin/python /etc/python2.6 /etc/python /usr/lib/python2.6 /usr/lib/python3.1 /usr/lib64/python2.6 /usr/lib64/python3.1 /usr/local/bin/python2.7-config /usr/local/bin/python /usr/local/bin/python2.7 /usr/local/lib/python2.6 /usr/local/lib/python2.7 /usr/include/python2.6 /usr/share/python /usr/share/man/man1/python.1.gz
How can I install pysftp?
You need to reinstall pip for Python 2.7, then run pip2.7 install pysftp. You need a pip installation for each version of Python you want to use it with. The setuptools package is probably the easiest way to get going; you can simply run the following to do it all in one fell swoop:
wget https://bootstrap.pypa.io/ez_setup.py -O --no-check-certificate - | sudo python2.7 && sudo easy_install-2.7 pip && sudo pip2.7 install pysftp
Sometimes older Linux installs have issues with the above command, due to an "invalid" certificate encounted while downloading the full setuptools package via ez_setup.py (see here for more details). This can be circumvented with this alternative one-fell-swoop command:
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-18.8.1.zip --no-check-certificate && unzip setuptools-18.8.1.zip && cd setuptools-18.8.1 && sudo python setup.py install && sudo easy_install-2.7 pip && sudo pip2.7 install pysftp
I think you need to install some sort of 'essentials package' using the code
sudo apt-get install build-essential libssl-dev libffi-dev python-dev
Then you can install :
sudo pip install pysftp
sudo pip install enum
I am on Debian Linux and I am trying to install Pyinstaller, for making a standalone exe file from python script, into my debian linux. I downloaded from this link to get Pyinstaller. But can't find proper installation instruction and found one discussion here.
What I did was
(1) go to the pyinstaller folder and
sudo python setup.py
The error is
Traceback (most recent call last):
File "setup.py", line 14, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools
(2) I don't have source/linux folder in my Pyinstaller folder according to the discussion in the second link.
Where can I find proper instruction for the installation. Even in this manual, it is not clear how to install for Linux.
Thanks
you need to install python-setuptools
sudo apt-get install python-setuptools
Installation pyinstaller:
You can pip install the pyinstaller
pip install pyinstaller
if you do not have pip then you can install pip using
sudo apt-get install python-pip