Python error importing module pandas "name 'GET' is not defined" - python

I have the most updated numpy, httplib2, pytz, Cython, python-dateutil & numexpr
And newest pandas build
But I'm flummoxed! The following code gives the following rather cryptic error. What is it trying to tell me?
import pandas
print "ok pandas"
error:
Traceback (most recent call last):
File "sank.py", line 1, in <module>
import pandas
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.14.1-py2.7-macosx-10.6-intel.egg/pandas/__init__.py", line 45, in <module>
from pandas.io.api import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.14.1-py2.7-macosx-10.6-intel.egg/pandas/io/api.py", line 15, in <module>
from pandas.io.gbq import read_gbq
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.14.1-py2.7-macosx-10.6-intel.egg/pandas/io/gbq.py", line 59, in <module>
import httplib2
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py", line 1070, in <module>
from google.appengine.api import apiproxy_stub_map
File "/Users/maggielee/Documents/pythons/google.py", line 32, in <module>
GET / HTTP/1.0
NameError: name 'GET' is not defined

Solution by furas and OP.
I had an old file called google.py. Just renamed/deleted it and problem was solved.
Probably python uses this file when it imports from google.appengine.api.

Related

Glitch in html5lib?

I'm getting this error. Is it a bug or is it a code error? What does it mean?
Traceback (most recent call last):
File "isc.py", line 8, in <module>
import requests, os, sys, bs4
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/bs4/__init__.py", line 30, in <module>
from .builder import builder_registry, ParserRejectedMarkup
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/bs4/builder/__init__.py", line 314, in <module>
from . import _html5lib
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/bs4/builder/_html5lib.py", line 70, in <module>
class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
AttributeError: module 'html5lib.treebuilders' has no attribute '_base'
(i upgraded html5lib bs4 and requests)
It's an issue related to your html5lib package version try upgrading it.

cannot import pyLDAvis - ModuleNotFoundError: No module named '_contextvars'

I am trying to import pyLDAvis but it gives the error ModuleNotFoundError: No module named '_contextvars' although I installed both pyLDAvis and contextvars. The error is as follows
Traceback (most recent call last):
File "C:/Users/ebru/Documents/Arda Docs/Mydocs/ITLS/Research/Tüpraş/Python Codes/Tupras_NLPv04.py", line 249, in <module>
import pyLDAvis
File "C:\Users\ebru\PycharmProjects\Tuprasv01\venv\lib\site-packages\pyLDAvis\__init__.py", line 44, in <module>
from ._display import *
File "C:\Users\ebru\PycharmProjects\Tuprasv01\venv\lib\site-packages\pyLDAvis\_display.py", line 7, in <module>
import jinja2
File "C:\Users\ebru\PycharmProjects\Tuprasv01\venv\lib\site-packages\jinja2\__init__.py", line 82, in <module>
_patch_async()
File "C:\Users\ebru\PycharmProjects\Tuprasv01\venv\lib\site-packages\jinja2\__init__.py", line 78, in _patch_async
from jinja2.asyncsupport import patch_all
File "C:\Users\ebru\PycharmProjects\Tuprasv01\venv\lib\site-packages\jinja2\asyncsupport.py", line 13, in <module>
import asyncio
File "C:\Users\ebru\AppData\Local\Programs\Python\Python37-32\lib\asyncio\__init__.py", line 8, in <module>
from .base_events import *
File "C:\Users\ebru\AppData\Local\Programs\Python\Python37-32\lib\asyncio\base_events.py", line 39, in <module>
from . import events
File "C:\Users\ebru\AppData\Local\Programs\Python\Python37-32\lib\asyncio\events.py", line 14, in <module>
import contextvars
File "C:\Users\ebru\AppData\Local\Programs\Python\Python37-32\lib\contextvars.py", line 1, in <module>
from _contextvars import Context, ContextVar, Token, copy_context
ModuleNotFoundError: No module named '_contextvars'
I tried to delete the underscore in contextvars.py but it did not work.
Plotting tools
import pyLDAvis
import pyLDAvis.sklearn
According to https://github.com/axnsan12/drf-yasg/issues/362#issuecomment-494360308, this problem might result from virtualenv not upgrading to the Python version you have installed.
Also, 3.7.4 has been released & includes changes related to Context Variables. Maybe upgrading to that helps?

Error in importing requests module in python3

I am using requests module in my python program. It worked great in the previous day. But now, when importing requests module, it is showing a weird error. It is working great in python2 version. But shows error in python3. I googled it but can't find a solution. I haven't changed anything. Why it is showing this error.
Here it is:
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/paulsteven/.local/lib/python3.5/site-packages/requests/__init__.py", line 95, in <module>
from urllib3.contrib import pyopenssl
File "/home/paulsteven/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/home/paulsteven/.local/lib/python3.5/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/home/paulsteven/.local/lib/python3.5/site-packages/OpenSSL/rand.py", line 11, in <module>
from OpenSSL._util import (
File "/home/paulsteven/.local/lib/python3.5/site-packages/OpenSSL/_util.py", line 3, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "/home/paulsteven/.local/lib/python3.5/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 188, in <module>
_verify_package_version(cryptography.__version__)
File "/home/paulsteven/.local/lib/python3.5/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 175, in _verify_package_version
so_package_version = ffi.string(lib.CRYPTOGRAPHY_PACKAGE_VERSION)
AttributeError: cffi library '_openssl' has no function, constant or global variable named 'CRYPTOGRAPHY_PACKAGE_VERSION'
Reinstalling cryptography package will resolve this problem.

Python: Attribute Error When Importing Pandas From a Script

Pandas imports fail when I invoke a script from the command line. I can't identify what is causing this. Can anyone help me out? Thanks in advance!
Code
import pandas as pd
Error
root#vultr:~/Repos/solomon# python3 lib/scripts/dummy.py
Traceback (most recent call last):
File "lib/scripts/dummy.py", line 1, in <module>
import pandas as pd
File "/usr/local/lib/python3.5/dist-packages/pandas/__init__.py", line 42, in <module>
from pandas.core.api import *
File "/usr/local/lib/python3.5/dist-packages/pandas/core/api.py", line 10, in <module>
from pandas.core.groupby import Grouper
File "/usr/local/lib/python3.5/dist-packages/pandas/core/groupby.py", line 50, in <module>
from pandas.core.frame import DataFrame
File "/usr/local/lib/python3.5/dist-packages/pandas/core/frame.py", line 69, in <module>
from pandas.core.generic import NDFrame, _shared_docs
File "/usr/local/lib/python3.5/dist-packages/pandas/core/generic.py", line 48, in <module>
from pandas.io.formats.format import format_percentiles, DataFrameFormatter
File "/usr/local/lib/python3.5/dist-packages/pandas/io/formats/format.py", line 36, in <module>
from pandas.io.common import (_get_handle, UnicodeWriter, _expand_user,
File "/usr/local/lib/python3.5/dist-packages/pandas/io/common.py", line 484, in <module>
def UnicodeReader(f, dialect=csv.excel, encoding="utf-8", **kwds):
AttributeError: module 'csv' has no attribute 'excel'
Did you interrupted pandas installation?
Try to upgrade
(first install pip if you don't have it)
https://pip.pypa.io/en/stable/installing/
then
pip install pandas --upgrade
Solved:
It was because I had a directory named "csv" in the same directory as the run script. Stupid mistake. Sorry guys and gals.

Import Error: cannot import pivot_simple

I am using Ubuntu system with python 2.7 and pandas version of 0.19.I have been trying to run a python file and this error keeps on showing up-
>>> import file.py as x
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "file.py", line 4, in <module>
import pandas as pd
File "/home/user/.local/lib/python2.7/site-packages/pandas/__init__.py", line 39, in <module>
from pandas.core.api import *
File "/home/user/.local/lib/python2.7/site-packages/pandas/core/api.py", line 20, in <module>
from pandas.core.reshape import (pivot_simple as pivot, get_dummies,
ImportError: cannot import name pivot_simple
Please help me in resolving the issue by telling the possible issues for this error and the way it can be removed.
Thanks!
instead of using 'files.py'
please try 'import files as x'

Categories