python-apt icon indicating copy to clipboard operation
python-apt copied to clipboard

pip update error

Open combab0 opened this issue 8 years ago • 11 comments

root@ubuntu:~/source/fail2ban# pip list | grep python-apt
python-apt (0.9.3.5ubuntu2)
root@ubuntu:~/source/fail2ban# pip install --upgrade python-apt
Collecting python-apt
  Using cached 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-build-fPcLQq/python-apt/setup.py", line 11, in <module>
        string.split(parse_makefile("python/makefile")["APT_PKG_SRC"]))
      File "/usr/lib/python2.7/distutils/sysconfig.py", line 304, in parse_makefile
        fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1)
      File "/usr/lib/python2.7/distutils/text_file.py", line 103, in __init__
        self.open (filename)
      File "/usr/lib/python2.7/distutils/text_file.py", line 120, in open
        self.file = open (self.filename, 'r')
    IOError: [Errno 2] No such file or directory: 'python/makefile'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-fPcLQq/python-apt/

how can i solve it?

combab0 avatar Apr 15 '16 11:04 combab0

@hdarwin hi! You solved this problem?

reddoggad avatar Jun 23 '16 22:06 reddoggad

Hm, before install libapt-pkg-dev pip install https://launchpad.net/python-apt/main/0.7.8/+download/python-apt-0.8.5.tar.gz

reddoggad avatar Jun 23 '16 22:06 reddoggad

Hi, have anyone solved this issue?

HalisCz avatar Jul 26 '16 11:07 HalisCz

@HalisCz, installing python-apt as @reddoggad suggests solves it for me.

kotnik avatar Aug 01 '16 12:08 kotnik

For me too. Thanks

HalisCz avatar Aug 25 '16 08:08 HalisCz

I'm having the same problem, putting here my solution for reference.

The Pypi version of python-apt package it's not updated. Usually the best is to install the system apt python-apt package, but sometimes running a virtualenv isolated from the system you also need to install the python package.

I've found the Debian repository of python-apt and install it with pip using the correct branch for my system:

sudo apt-get install libapt-pkg-dev  # so gcc find the <apt-pkg/hashes.h>
pip install git+https://anonscm.debian.org/cgit/apt/python-apt.git@ubuntu/trusty

and it works.

tinproject avatar Apr 28 '17 15:04 tinproject

@tinproject I'm facing the same issue but the second command fails:

Collecting git+https://anonscm.debian.org/cgit/apt/python-apt.git
  Cloning https://anonscm.debian.org/cgit/apt/python-apt.git to /tmp/pip-uh0FwI-build fatal: unable to access 'https://anonscm.debian.org/cgit/apt/python-apt.git/': Failed  to connect to anonscm.debian.org port 443: Connection refused
Command "git clone -q https://anonscm.debian.org/cgit/apt/python-apt.git /tmp/pip-uh0 FwI-build" failed with error code 128 in None

imagen

Did the url changed? Thanks!

EDIT: I'm using Windows 10

aaossa avatar Nov 10 '17 17:11 aaossa

@aaossa You are not including the branch/tag part of the git repo at the pip command. Also I do not know why you want to install python-apt package in a non Debian system...

On Linux Mint 18 I've found that there is no ubuntu/xenial branch, but using the tag 1.1.0_beta5 it works.

tinproject avatar Nov 10 '17 18:11 tinproject

I tried because when I wanted to update my python packaged it was listed as outdated (python-apt (0.9.3.5ubuntu2) - Latest: 0.7.8 [sdist]). After that I tried to update all of them but python-apt failed. I'll try your suggestiong. Thanks!

aaossa avatar Nov 10 '17 18:11 aaossa

The new URL is https://salsa.debian.org/apt-team/python-apt.git. Thanks @tinproject for the pointer! :es:

astrojuanlu avatar Aug 22 '18 14:08 astrojuanlu

Just chiming in to confirm: I had the same problem, and making this change to my requirements.txt file fixed it:

diff --git a/requirements.txt b/requirements.txt
index 92fb4e5..6ca12d7 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,4 @@
 ansible
+git+https://salsa.debian.org/apt-team/[email protected]
 molecule
 psutil

In my case, though, for an Ubuntu 20.04 target, I also needed to run:

$ sudo apt install libapt-pkg-dev

in order for pip install -r requirements.txt to succeed. Without this package installed, I kept getting this error:

    running build_ext
    building 'apt_pkg' extension
    creating build/temp.linux-x86_64-3.9
    creating build/temp.linux-x86_64-3.9/python
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/evadeflow/projects/ubuntu-vm-setup/venv/include -I/usr/include/python3.9 -c python/acquire-item.cc -o build/temp.linux-x86_64-3.9/python/acquire-item.o -std=c++11 -Wno-write-strings -DAPT_8_CLEANER_HEADERS -DAPT_9_CLEANER_HEADERS -DAPT_10_CLEANER_HEADERS -DPY_SSIZE_T_CLEAN
    In file included from python/acquire-item.cc:24:
    python/apt_pkgmodule.h:14:10: fatal error: apt-pkg/hashes.h: No such file or directory
       14 | #include <apt-pkg/hashes.h>
          |          ^~~~~~~~~~~~~~~~~~
    compilation terminated.
    error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1

But the error that started this whole odyssey was this:

    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'

(I'm selfishly including that last bit so that Google will lead me back to this page if/when I encounter the same error in the future...)

evadeflow avatar Nov 09 '20 16:11 evadeflow