Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird errors with pyenv; File <string> key error #2038

Closed
danielecook opened this issue Jul 31, 2016 · 17 comments
Closed

Weird errors with pyenv; File <string> key error #2038

danielecook opened this issue Jul 31, 2016 · 17 comments
Assignees

Comments

@danielecook
Copy link

Every time I invoke python I see a long list of google python modules reporting errors.

Error processing line 2 of /usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site-packages/gax_google_logging_v2-0.7.12-py2.7-nspkg.pth:

Traceback (most recent call last):
File "/usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site.py", line 152, in addpackage
exec line
File "", line 1, in
KeyError: 'google'

Remainder of file ignored
Error processing line 2 of /usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site-packages/gax_google_pubsub_v1-0.7.12-py2.7-nspkg.pth:

  Traceback (most recent call last):
    File "/usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site.py", line 152, in addpackage
      exec line
    File "<string>", line 1, in <module>
  KeyError: 'google'

Remainder of file ignored
Error processing line 2 of /usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site-packages/googleapis_common_protos-1.2.0-py2.7-nspkg.pth:

  Traceback (most recent call last):
    File "/usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site.py", line 152, in addpackage
      exec line
    File "<string>", line 1, in <module>
  KeyError: 'google'

Remainder of file ignored
Error processing line 2 of /usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site-packages/grpc_google_logging_v2-0.7.12-py2.7-nspkg.pth:

  Traceback (most recent call last):
    File "/usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site.py", line 152, in addpackage
      exec line
    File "<string>", line 1, in <module>
  KeyError: 'google'

Remainder of file ignored
Error processing line 2 of /usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site-packages/grpc_google_pubsub_v1-0.7.12-py2.7-nspkg.pth:

  Traceback (most recent call last):
    File "/usr/local/var/pyenv/versions/2.7.11/lib/python2.7/site.py", line 152, in addpackage
      exec line
    File "<string>", line 1, in <module>
  KeyError: 'google'
@daspecster
Copy link
Contributor

Hello @danielecook!

There is a similar issue for another package on stackoverflow and they suggest uninstalling and reinstalling.

Is this a fresh virtual environment that you've installed gcloud-python in?

@danielecook
Copy link
Author

That fixed it. Thanks!

@daspecster
Copy link
Contributor

daspecster commented Aug 1, 2016

Great to hear, and thanks for letting us know!

@richardbaronpenman
Copy link

I got the same error message and needed to remove the following packages:

pip uninstall google-cloud-bigquery google-cloud-core googleapis-common-protos

However reinstalling them produces the same error. Any idea what is going on?
OSX 10.11.6, Python 2.7.

@dhermes
Copy link
Contributor

dhermes commented Dec 14, 2016

Have not experienced this. Can you provide some commands so we can try to reproduce?

@richardbaronpenman
Copy link

Basically if I add any of these packages like this:

pip install google-cloud-bigquery google-cloud-core googleapis-common-protos

Then when use Python command get the warning messages like above:

$ python
Error processing line 3 of /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google_cloud_bigquery-0.22.1-py2.7-nspkg.pth:

  Traceback (most recent call last):
    File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 152, in addpackage
      exec line
    File "<string>", line 1, in <module>
  KeyError: 'google'

Remainder of file ignored
Error processing line 3 of /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google_cloud_core-0.22.1-py2.7-nspkg.pth:

  Traceback (most recent call last):
    File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 152, in addpackage
      exec line
    File "<string>", line 1, in <module>
  KeyError: 'google'

Remainder of file ignored
Error processing line 2 of /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleapis_common_protos-1.5.0-py2.7-nspkg.pth:

  Traceback (most recent call last):
    File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 152, in addpackage
      exec line
    File "<string>", line 1, in <module>
  KeyError: 'google'

Remainder of file ignored
Python 2.7.11 (default, Dec 26 2015, 17:47:53)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

@dhermes
Copy link
Contributor

dhermes commented Dec 14, 2016

Got it. So it's the same error as reported. I think the issue may be with how you are uninstalling. pip uninstall may not actually pick up the offending pth files.

Have you tried in a brand new virtual environment?

@richardbaronpenman
Copy link

Yes they work fine in a fresh virtualenv, or on my Linux server.

@dhermes
Copy link
Contributor

dhermes commented Dec 14, 2016

So it's definitely an issue with the environment. Sorry your install got borked. I'm happy to help you grep around for the pth files.

@richardbaronpenman
Copy link

Thanks, here are the contents of the offending pth files:

google_cloud_bigquery-0.22.1-py2.7-nspkg.pth:

import sys, types, os;pep420 = sys.version_info > (3, 3);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('google',));ie = os.path.exists(os.path.join(p,'__init__.py'));m = not ie and not pep420 and sys.modules.setdefault('google', types.ModuleType('google'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
import sys, types, os;pep420 = sys.version_info > (3, 3);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('google',));ie = os.path.exists(os.path.join(p,'__init__.py'));m = not ie and not pep420 and sys.modules.setdefault('google', types.ModuleType('google'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
import sys, types, os;pep420 = sys.version_info > (3, 3);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('google', 'cloud'));ie = os.path.exists(os.path.join(p,'__init__.py'));m = not ie and not pep420 and sys.modules.setdefault('google.cloud', types.ModuleType('google.cloud'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p);m and setattr(sys.modules['google'], 'cloud', m)

google_cloud_core-0.22.1-py2.7-nspkg.pth

import sys, types, os;pep420 = sys.version_info > (3, 3);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('google',));ie = os.path.exists(os.path.join(p,'__init__.py'));m = not ie and not pep420 and sys.modules.setdefault('google', types.ModuleType('google'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
import sys, types, os;pep420 = sys.version_info > (3, 3);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('google',));ie = os.path.exists(os.path.join(p,'__init__.py'));m = not ie and not pep420 and sys.modules.setdefault('google', types.ModuleType('google'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
import sys, types, os;pep420 = sys.version_info > (3, 3);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('google', 'cloud'));ie = os.path.exists(os.path.join(p,'__init__.py'));m = not ie and not pep420 and sys.modules.setdefault('google.cloud', types.ModuleType('google.cloud'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p);m and setattr(sys.modules['google'], 'cloud', m)

googleapis_common_protos-1.5.0-py2.7-nspkg.pth

import sys, types, os;p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('google',));ie = os.path.exists(os.path.join(p,'__init__.py'));m = not ie and sys.modules.setdefault('google', types.ModuleType('google'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
import sys, types, os;p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('google', 'logging'));ie = os.path.exists(os.path.join(p,'__init__.py'));m = not ie and sys.modules.setdefault('google.logging', types.ModuleType('google.logging'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p);m and setattr(sys.modules['google'], 'logging', m)

Does anything look out of order there?

And here are the list of google API modules installed with pip:

google-auth (0.4.0)
google-auth-httplib2 (0.0.2)
google-cloud-bigquery (0.22.1)
google-cloud-core (0.22.1)
googleapis-common-protos (1.5.0)

@dhermes
Copy link
Contributor

dhermes commented Dec 15, 2016

I'm not clear on what the error is, but you should just forcefully remove the pth files and reinstall. Hopefully this fixes the issue.

@richardbaronpenman
Copy link

Those files are deleted when uninstall the modules and the above errors disappear, but reinstalling creates them again.

@dhermes
Copy link
Contributor

dhermes commented Dec 15, 2016

Do you have some files in tthe site-packages/google directory that AREN'T namespace packages?

@richardbaronpenman
Copy link

Here are the contents of that directory:

$ ls /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google
__init__.py   __init__.pyc  auth/         oauth2/       protobuf/

@treetoc
Copy link

treetoc commented Jan 10, 2018

Did anyone solve that issue?

@tseaver
Copy link
Contributor

tseaver commented Jan 10, 2018

@treetoc the original poster reported that installing in a fresh virtual environment fixed the problem.

@pulkitv52
Copy link

Microsoft Windows [Version 10.0.19043.1766]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Admin>python --version
Python 3.10.4

C:\Users\Admin>
C:\Users\Admin> pip3 install numpy
Error processing line 1 of C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\google_auth-2.6.6-py3.10-nspkg.pth:

Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site.py", line 186, in addpackage
exec(line)
File "", line 1, in
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\importlib\util.py", line 14, in
from contextlib import contextmanager
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 5, in
from collections import deque
ImportError: cannot import name 'deque' from 'collections' (C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\collections_init_.py)

Remainder of file ignored
Error processing line 1 of C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib-3.5.2-py3.10-nspkg.pth:

Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site.py", line 186, in addpackage
exec(line)
File "", line 1, in
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\importlib\util.py", line 14, in
from contextlib import contextmanager
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 5, in
from collections import deque
ImportError: cannot import name 'deque' from 'collections' (C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\collections_init_.py)

Remainder of file ignored
Error processing line 1 of C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\protobuf-3.19.4-py3.10-nspkg.pth:

Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site.py", line 186, in addpackage
exec(line)
File "", line 1, in
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\importlib\util.py", line 14, in
from contextlib import contextmanager
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 5, in
from collections import deque
ImportError: cannot import name 'deque' from 'collections' (C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\collections_init_.py)

Remainder of file ignored
Could not import runpy module
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 15, in
import importlib.util
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\importlib\util.py", line 14, in
from contextlib import contextmanager
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 5, in
from collections import deque
ImportError: cannot import name 'deque' from 'collections' (C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\collections_init_.py)

this is the error when i am using pip command everytime pls help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants