Unable to install `python-apt` package because of `DistUtilsExtra` module not found
See original GitHub issue- I have searched the issues of this repo and believe that this is not a duplicate.
- I have searched the documentation and believe that my question is not covered.
Question
Hi!
Some info before asking the question:
- Poetry 1.0.0b1
- Poetry setup a virtualenv with Python 3.7
I’m trying to install python-apt
package (for using apt module in Ansible), but I’m facing this error:
➜ System git:(feat/dconf) ✗ poetry add python-apt
Using version ^0.7.8 for python-apt
Updating dependencies
Resolving dependencies... (0.1s)
Package operations: 1 install, 0 updates, 0 removals
- Installing python-apt (0.7.8)
[EnvCommandError]
Command ['/home/kocal/.cache/pypoetry/virtualenvs/system-H90qh8t--py3.7/bin/python', '-m', 'pip', 'install', '--no-deps', 'python-apt==0.7.8'] errored with the following return code 1, and output:
Collecting python-apt==0.7.8
Using cached https://files.pythonhosted.org/packages/e5/ff/63bb64a103eda6f13364381e983c0121eeacc337a4421d6005ff7dd76741/python-apt-0.7.8.tar.bz2
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-hcb_ok5s/python-apt/setup.py", line 6, in <module>
from DistUtilsExtra.command import *
ModuleNotFoundError: No module named 'DistUtilsExtra'
Indeed, I don’t see any distutils
library in my virtualenv libraries:
➜ System git:(feat/dconf) ✗ l ~/.cache/pypoetry/virtualenvs/system-H90qh8t--py3.7/lib/python3.7/site-packages
total 88K
drwxr-xr-x 21 kocal kocal 4,0K sept. 7 07:37 .
drwxr-xr-x 3 kocal kocal 4,0K sept. 7 07:36 ..
drwxr-xr-x 18 kocal kocal 4,0K sept. 7 07:36 ansible
drwxr-xr-x 2 kocal kocal 4,0K sept. 7 07:37 ansible-2.7.5.egg-info
-rw-r--r-- 1 kocal kocal 126 sept. 7 07:36 easy_install.py
drwxr-xr-x 3 kocal kocal 4,0K sept. 7 07:37 jinja2
drwxr-xr-x 2 kocal kocal 4,0K sept. 7 07:37 Jinja2-2.10.dist-info
drwxr-xr-x 3 kocal kocal 4,0K sept. 7 07:37 jmespath
drwxr-xr-x 2 kocal kocal 4,0K sept. 7 07:37 jmespath-0.9.3.dist-info
drwxr-xr-x 3 kocal kocal 4,0K sept. 7 07:36 markupsafe
drwxr-xr-x 2 kocal kocal 4,0K sept. 7 07:36 MarkupSafe-1.1.0.dist-info
drwxr-xr-x 5 kocal kocal 4,0K sept. 7 07:36 pip
drwxr-xr-x 2 kocal kocal 4,0K sept. 7 07:36 pip-18.1.dist-info
drwxr-xr-x 5 kocal kocal 4,0K sept. 7 07:36 pkg_resources
drwxr-xr-x 2 kocal kocal 4,0K sept. 7 07:36 pkg_resources-0.0.0.dist-info
drwxr-xr-x 4 kocal kocal 4,0K sept. 7 07:37 psutil
drwxr-xr-x 2 kocal kocal 4,0K sept. 7 07:37 psutil-5.6.3.egg-info
drwxr-xr-x 2 kocal kocal 4,0K sept. 7 07:36 __pycache__
drwxr-xr-x 2 kocal kocal 4,0K sept. 7 07:37 PyYAML-5.1.1.egg-info
drwxr-xr-x 6 kocal kocal 4,0K sept. 7 07:36 setuptools
drwxr-xr-x 2 kocal kocal 4,0K sept. 7 07:36 setuptools-40.8.0.dist-info
drwxr-xr-x 3 kocal kocal 4,0K sept. 7 07:37 yaml
But I don’t find how to install distutils
with Poetry.
It seems that distutils
is only installable with system’s package manager: sudo apt-get install python3-distutils
.
I know that I’ve already ran this command, so distutils
is installed for the global Python interpreter:
➜ System git:(feat/dconf) ✗ l /usr/lib/python3.7/distutils
total 500K
drwxr-xr-x 4 root root 4,0K juin 1 06:27 .
drwxr-xr-x 31 root root 20K juil. 12 06:33 ..
-rw-r--r-- 1 root root 8,4K mars 26 08:58 archive_util.py
-rw-r--r-- 1 root root 15K mars 26 08:58 bcppcompiler.py
-rw-r--r-- 1 root root 47K mars 26 08:58 ccompiler.py
-rw-r--r-- 1 root root 18K mars 26 08:58 cmd.py
drwxr-xr-x 3 root root 4,0K juin 1 06:27 command
-rw-r--r-- 1 root root 4,8K mars 26 08:58 config.py
-rw-r--r-- 1 root root 8,7K mars 26 08:58 core.py
-rw-r--r-- 1 root root 17K mars 26 08:58 cygwinccompiler.py
-rw-r--r-- 1 root root 139 mars 26 08:58 debug.py
-rw-r--r-- 1 root root 3,5K mars 26 08:58 dep_util.py
-rw-r--r-- 1 root root 8,2K mars 26 08:58 dir_util.py
-rw-r--r-- 1 root root 50K mars 26 08:58 dist.py
-rw-r--r-- 1 root root 3,5K mars 26 08:58 errors.py
-rw-r--r-- 1 root root 11K mars 26 08:58 extension.py
-rw-r--r-- 1 root root 18K mars 26 08:58 fancy_getopt.py
-rw-r--r-- 1 root root 13K mars 26 08:58 filelist.py
-rw-r--r-- 1 root root 8,0K mars 26 08:58 file_util.py
-rw-r--r-- 1 root root 236 avril 3 07:39 __init__.py
-rw-r--r-- 1 root root 2,0K mars 26 08:58 log.py
-rw-r--r-- 1 root root 30K mars 26 08:58 msvc9compiler.py
-rw-r--r-- 1 root root 22K mars 26 08:58 _msvccompiler.py
-rw-r--r-- 1 root root 24K mars 26 08:58 msvccompiler.py
drwxr-xr-x 2 root root 4,0K juin 1 06:27 __pycache__
-rw-r--r-- 1 root root 295 mars 26 08:58 README
-rw-r--r-- 1 root root 7,3K mars 26 08:58 spawn.py
-rw-r--r-- 1 root root 22K mars 26 08:58 sysconfig.py
-rw-r--r-- 1 root root 13K mars 26 08:58 text_file.py
-rw-r--r-- 1 root root 15K mars 26 08:58 unixccompiler.py
-rw-r--r-- 1 root root 20K mars 26 08:58 util.py
-rw-r--r-- 1 root root 5,1K mars 26 08:58 versionpredicate.py
-rw-r--r-- 1 root root 13K avril 3 07:39 version.py
but I can’t use it through Poetry.
Did anyone already encountered the issue? 😕
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
How can I install DistUtilsExtra on Python compiled from ...
python3-distutils-extra appears to just be a python package, but I can't seem to find it on pypi. Is there a way to install...
Read more >python - DistutilsExtra problem - Ask Ubuntu
I beleive it has something to do with paths, but I am fairly new to Linux OS. I am working on source /opt/project_name/bin/activate...
Read more >I encounter "No module named DistUtilsExtra.command ...
I'm trying to import this python library. When I run the command `pip install python-apt` I get the following error. Collecting python-apt
Read more >ModuleNotFoundError: No module named ... - Google Groups
On Ubuntu 20.04.3 LTS, I try to install pdfarranger [1] as follows but failed: $ sudo apt-get install python3-pip python3-distutils-extra \
Read more >modulenotfounderror: no module named 'distutilsextra'
python-poetry/poetryUnable to install `python-apt` package because of `DistUtilsExtra` module not found#1363. Created over 3 years ago.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Top GitHub Comments
I had a similar issue, starting with this error from Ansible when using a non-APT Python 3.7 in a virtualenv:
Trying to install
python-apt
led to the same problem that you had with the error about DistUtilsExtra, but installingpython-apt
from PyPA is not the right solution, as it’s very old, and distutils is a red herring as well.Instead, here’s what did work for Ubuntu 18.04, by installing the APT package
python3-apt
into the virtualenv in a rather hacky way.I’m not using poetry for this but I am using a virtualenv and Python 3.7 (to get ansible-vault to decrypt properly), so I think this solution will work along with poetry. (BTW I like poetry but have other priorities right now.)
This is based on the very helpful solution by @acardak - that issue is locked so I thought I would comment here. I had to adjust that solution a little (version numbers in filenames) so it worked on fully updated Ubuntu 18.04.
Your solution helped me alot, @rdonkin. To show my gratitude I allowed myself to port your solution into an ansible script : )
Greetings