Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'NoneType' object has no attribute 'loader'

Tags:

python

pip

ubuntu

having an issue today when I started up my laptop (Ubuntu 18.4) and trying to use pip to install packages, I'm met with this error:

Error processing line 3 of /home/cjones/.local/lib/python3.6/site-packages/googleapis_common_protos-1.5.8-py3.6-nspkg.pth:    Traceback (most recent call last):     File "/usr/lib/python3.6/site.py", line 174, in addpackage       exec(line)     File "<string>", line 1, in <module>     File "<frozen importlib._bootstrap>", line 568, in module_from_spec   AttributeError: 'NoneType' object has no attribute 'loader'  Remainder of file ignored 

I don't think I changed anything since last successful boot but it seems as though something is missing... can anyone help?

like image 992
Cam Avatar asked Jul 08 '19 13:07

Cam


2 Answers

Delete /home/cjones/.local/lib/python3.6/site-packages/googleapis_common_protos-1.5.8-py3.6-nspkg.pth and retry.

like image 155
Chankey Pathak Avatar answered Sep 28 '22 10:09

Chankey Pathak


I had the similar problem, but the error message referenced a different .pth file. The error message I received was:

Error processing line 1 of /Users/jt/anaconda3/lib/python3.7/site-packages/sphinxcontrib.datatemplates-nspkg.pth:    Traceback (most recent call last):     File "/Users/jt/anaconda3/lib/python3.7/site.py", line 168, in addpackage       exec(line)     File "<string>", line 1, in <module>     File "<frozen importlib._bootstrap>", line 580, in module_from_spec   AttributeError: 'NoneType' object has no attribute 'loader'  Remainder of file ignored 

Following the solution described here:

https://github.com/Pyomo/pyomo/issues/95

I edited the .pth file (the file at the start of the error message, immediately after the text Error processing line 1 of) and added a newline character after the first semicolon. That is, I changed:

import sys, types, os;has_mfs = sys.version_info > (3, 5);p ...<rest of file> 

To:

import sys, types, os; has_mfs = sys.version_info > (3, 5);p ...<rest of file> 

I don't know why this worked, but it did.

like image 36
jeffteeters Avatar answered Sep 28 '22 09:09

jeffteeters