Pip version mismatch

raspberrypi3

#1

Hi, on several of the beginner examples, I’m seeing a pip error that causes the build to fail:
ImportError: cannot import name _remove_dead_weakref
…research online suggests this is because there’s a mismatch between versions of pip, but putting
RUN pip install --upgrade pip
results in the same error.

I’m a beginner, so my apologies if there’s something obvious I’m not understanding. Any help or pointers you could provide would be appreciated!

AKA


#4

Hey there, can you post which base image you are using? From what I can find this error suggests a conflict in Python installations – are you manually installing Python in your Dockerfile?


#5

Thanks for the quick reply!

Right now I’m trying to implement this on a RasPi Zero W. The base image was resin/%%RESIN_MACHINE_NAME%%-python:2.7 and I also tried removing the version in hopes of getting the latest, ie resin/%%RESIN_MACHINE_NAME%%-python

Earlier in the week, I tried the example here and the example here. In both of those cases, I was trying to add stuff (python’s omxplayer wrapper, Adafruit GPIO, and some others) via the requirements.txt file, but encountered this same error at some point in both cases.

I yak-shaved so much on both of the prior repos that I eventually lost track. So for the wifi-connect-example repo, I’m asking for help before doing a lot of flailing :wink:

To answer your question, I’m not installing python in the dockerfile…in fact, just as a sanity check, I reverted back to the unaltered dockerfile in that repo and still encountered the error in the first post. I’m very puzzled as to what I’m doing wrong!

Thanks again for any help / hints you can provide - happy to put a gist or pastebin up if that would help!

AKA


#6

Ah, looking more at why the unaltered repo does not work, I see this issue indicating incompatibility with the latest version of wifi-connect.
I’d be happy to take a stab at updating it, but I’ll have to read both codebases more carefully to take stock of what has changed…hints appreciated!

AKA


#7

Here is the command line output when trying to build the unaltered resin-wifi-connect-example app:

AKA-2016air:resin-wifi-connect-example AKA$ git push resin master --force
Counting objects: 65, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (63/63), done.
Writing objects: 100% (65/65), 3.86 MiB | 647.00 KiB/s, done.
Total 65 (delta 27), reused 0 (delta 0)

[Info]  Starting build for fixturezero, user nfeehan
[Info]  Dashboard link: https://dashboard.resin.io/apps/1005177/devices
[Info]  Building on arm01
[Info]  Pulling previous images for caching purposes...
[Success]  Successfully pulled cache images
[main]  Step 1/12 : FROM resin/raspberry-pi-python:2.7
[main]   ---> e63f4d9087a7
[main]  Step 2/12 : LABEL maintainer "Joe Roberts <joe@resin.io>, Zahari Petkov <zahari@resin.io>"
[main]  Using cache
[main]   ---> 82efcede4354
[main]  Step 3/12 : ENV INITSYSTEM on
[main]  Using cache
[main]   ---> 85f96180c848
[main]  Step 4/12 : WORKDIR /usr/src/app
[main]  Using cache
[main]   ---> 6dcdc077ccf5
[main]  Step 5/12 : ENV DEVICE_TYPE raspberry-pi
[main]  Using cache
[main]   ---> 8b7002c95c5c
[main]  Step 6/12 : RUN apt-get update && apt-get install -yq --no-install-recommends     dnsmasq &&     apt-get clean && rm -rf /var/lib/apt/lists/*
[main]  Using cache
[main]   ---> 24da48ffc26d
[main]  Step 7/12 : RUN curl https://api.github.com/repos/resin-io/resin-wifi-connect/releases/latest -s     | grep -hoP 'browser_download_url": "\K.*rpi\.tar\.gz'     | xargs -n1 curl -Ls     | tar -xvz -C /usr/src/app/
[main]  Using cache
[main]   ---> 3d6478aa79ac
[main]  Step 8/12 : RUN apt-get update && apt-get install -yq --no-install-recommends     python-dev     python-smbus     python-psutil     wireless-tools &&     apt-get clean && rm -rf /var/lib/apt/lists/*
[main]  Using cache
[main]   ---> 7d8c344aa43b
[main]  Step 9/12 : RUN pip install --upgrade pip
[main]   ---> Running in 97f661e03755
[main]  Traceback (most recent call last):
[main]    File "/usr/local/bin/pip", line 7, in <module>
[main]      from pip import main
[main]    File "/usr/local/lib/python2.7/site-packages/pip/__init__.py", line 5, in <module>
[main]      import logging
[main]    File "/usr/local/lib/python2.7/logging/__init__.py", line 26, in <module>
[main]      import sys, os, time, cStringIO, traceback, warnings, weakref, collections
[main]    File "/usr/local/lib/python2.7/weakref.py", line 14, in <module>
[main]      from _weakref import (
[main]  ImportError: cannot import name _remove_dead_weakref
[main]
[main]  Removing intermediate container 97f661e03755
[main]  The command '/bin/sh -c pip install --upgrade pip' returned a non-zero code: 1
[Info]  Uploading images
[Success]  Successfully uploaded images
[Error]  Some services failed to build:
[Error]    Service: main
[Error]      Error: The command '/bin/sh -c pip install --upgrade pip' returned a non-zero code: 1
[Error]  Not deploying release.

remote: error: hook declined to update refs/heads/master

#8

I will work on investigating and fixing this tomorrow. I will post more information here once I have more information on what is causing this. It is definitely not WiFi Connect related, but some issue with the Python configuration in the base image. Should not be hard to track down and fix though.


#9

Thank you!! As I said, I’m a beginner, so I hope I’m not wasting everyone’s time here. If there’s specific debugging or other stuff I can try alongside you, please just let me know, happy to (try to) help…

Thanks again,

AKA


#11

I tracked this down to the part in the Dockerfile where python-dev is installed. The container base image uses a custom python installation and this one interferes with the provided by debian. Not using the debian python packages is intentional, but I do not know the exact details, so I need to check with the base image maintainers for how to fix the wifi-connect example specifically.

Also please do not worry about those types of troubleshooting questions. We are happy to help! And the problem is quite a valid one anyway, that has to be resolved.

We will post more information here as soon as we have an update.


#19

Comment from our base image maintainer: the way around this is to use a -debian base image and install python with apt-get, rather than using the -python base image.


#23

Thanks for this!
Do you happen to know all the apt-get packages I will have to install in order to have my debian image be just like the python base image?


#24

The python base images are pretty minimal - they include a virtualenv and dbus-python as additional items.