How to fix ImportError: cannot import name _remove_dead_weakref

Full Error Print

Traceback (most recent call last):
File "/usr/share/nginx/spotipo/.env/bin/pip", line 7, in <module>
from pip import main
File "/usr/share/nginx/spotipo/.env/local/lib/python2.7/site-packages/pip/__init__.py", line 5, in <module>
import logging
File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
import sys, os, time, cStringIO, traceback, warnings, weakref, collections
File "/usr/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
dpkg: error processing package spotipo (--configure):
installed spotipo package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
spotipo
E: Sub-process /usr/bin/dpkg returned an error code (1)

This error is usually seen while upgrading/installing spotipo. It might be caused by a recent OS upgrade.

Solution to ImportError: cannot import name _remove_dead_weakref

This error can be solved usually by removing the exisiting virtualenv and letting the installer create a new one.

Please follow below steps

sudo apt remove spotipo
sudo rm -rf /usr/share/nginx/spotipo/.env
sudo apt install spotipo

How did we do?


Powered by HelpDocs