How do I fix this? I want to use the Panda module, do I need to rename certain files?
When trying to import pandas, I get these errors:
Traceback (most recent call last):
File "C:\Users\Mathias\Documents\Cognitive Science\Cognition and Communication\Exam project\Embodiment_Exp.py", line 11, in <module>
import pandas as pd
File "C:\Python27\lib\site-packages\pandas\__init__.py", line 44, in <module>
from pandas.io.api import *
File "C:\Python27\lib\site-packages\pandas\io\api.py", line 15, in <module>
from pandas.io.gbq import read_gbq
File "C:\Python27\lib\site-packages\pandas\io\gbq.py", line 37, in <module>
AttributeError: 'module' object has no attribute 'getLogger'
This is to do with a filename clash, see https://github.com/pandas-dev/pandas/issues/10167
If you have a file named logging.py this needs to be renamed.
Related
I am trying to parse some protobuf messages and importing the messages module. However getting below error. Not sure what I am missing.
Please advise.
>>> import messages
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/dist-packages/messages/__init__.py", line 7, in <module>
from .api import send
File "/usr/local/lib/python3.8/dist-packages/messages/api.py", line 3, in <module>
from .email_ import Email
File "/usr/local/lib/python3.8/dist-packages/messages/email_.py", line 15, in <module>
from ._config import check_config_file
File "/usr/local/lib/python3.8/dist-packages/messages/_config.py", line 12, in <module>
import jsonconfig
File "/usr/local/lib/python3.8/dist-packages/jsonconfig/__init__.py", line 7, in <module>
from .core import Config
File "/usr/local/lib/python3.8/dist-packages/jsonconfig/core.py", line 11, in <module>
from .jsonutils import to_json_file, from_json_file
File "/usr/local/lib/python3.8/dist-packages/jsonconfig/jsonutils.py", line 29, in <module>
to_json = box._to_json
AttributeError: module 'box' has no attribute '_to_json'
This question already has answers here:
'module' object has no attribute 'loads' while parsing JSON using python [duplicate]
(2 answers)
Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError
(2 answers)
Closed 3 years ago.
I am trying to import Numpy
import numpy as np
but I am getting this error:
AttributeError: module 'linecache' has no attribute 'checkcache'
Full trace:
Traceback (most recent call last):
File "C:/Users/z1885/Desktop/鸡行为分析/codepy/ML/KNN.py", line 1, in <module>
import numpy as np
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\numpy\__init__.py", line 145, in <module>
from . import lib
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\numpy\lib\__init__.py", line 24, in <module>
from .npyio import *
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\numpy\lib\npyio.py", line 14, in <module>
from ._datasource import DataSource
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\numpy\lib\_datasource.py", line 41, in <module>
import shutil
File "C:\Users\z1885\Desktop\bouk\venv\lib\shutil.py", line 16, in <module>
import bz2
File "C:\Users\z1885\AppData\Local\Programs\Python\Python35\Lib\bz2.py", line 18, in <module>
from threading import RLock
File "C:\Users\z1885\AppData\Local\Programs\Python\Python35\Lib\threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
File "C:\Users\z1885\AppData\Local\Programs\Python\Python35\Lib\traceback.py", line 5, in <module>
import linecache
File "C:\Users\z1885\Desktop\bouk\venv\lib\linecache.py", line 11, in <module>
import tokenize
File "C:\Users\z1885\Desktop\bouk\venv\lib\tokenize.py", line 34, in <module>
from token import *
File "C:\Users\z1885\Desktop\鸡行为分析\codepy\token.py", line 5, in <module>
import request as request
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\request\__init__.py", line 2, in <module>
from get import GET
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\get\__init__.py", line 3, in <module>
from query_string import query_string
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\query_string\__init__.py", line 18, in <module>
#public.add
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\public\__init__.py", line 65, in add
return _add(_caller_modules()[1], objects)
File "C:\Users\z1885\Desktop\bouk\venv\lib\site-packages\public\__init__.py", line 12, in _caller_modules
frames = inspect.getouterframes(inspect.currentframe())
File "C:\Users\z1885\AppData\Local\Programs\Python\Python35\Lib\inspect.py", line 1441, in getouterframes
frameinfo = (frame,) + getframeinfo(frame, context)
File "C:\Users\z1885\AppData\Local\Programs\Python\Python35\Lib\inspect.py", line 1414, in getframeinfo
lines, lnum = findsource(frame)
File "C:\Users\z1885\AppData\Local\Programs\Python\Python35\Lib\inspect.py", line 747, in findsource
linecache.checkcache(file)
AttributeError: module 'linecache' has no attribute 'checkcache'
I'm new to Python and I'm trying to do a simple thread as follows.
import threading
def func(x):
print x
t1 = threading.Thread(target=func,args=("Hello",));
t1.start();
Then I got following error:
Traceback (most recent call last):
File "ex2.py", line 1, in <module>
import threading
File "/Users/treinetic-macbook/Desktop/threading.py", line 2, in <module>
File "/Library/Python/2.7/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/Library/Python/2.7/site-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Python/2.7/site-packages/urllib3/connectionpool.py", line 3, in <module>
import logging
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 207, in <module>
_lock = threading.RLock()
AttributeError: 'module' object has no attribute 'RLock'
can someone help me to understand this error?
/Users/treinetic-macbook/Desktop/threading.py is being imported because it's on your path somewhere. This is most likely not correct, try renaming that file and removing any threading.pyc file in your local dir.
I am using Python 3 and working on an ML project. My code ran fine for the first time but suddenly, out of nowhere, this error popped up.
Traceback (most recent call last):
File "<ipython-input-2-3ae66814e4b2>", line 1, in <module>
import pandas as pd
File "C:\Users\ruhani\Anaconda3\lib\site-packages\pandas\__init__.py", line 42, in <module>
from pandas.core.api import *
File "C:\Users\ruhani\Anaconda3\lib\site-packages\pandas\core\api.py", line 10, in <module>
from pandas.core.groupby import Grouper
File "C:\Users\ruhani\Anaconda3\lib\site-packages\pandas\core\groupby.py", line 49, in <module>
from pandas.core.frame import DataFrame
File "C:\Users\ruhani\Anaconda3\lib\site-packages\pandas\core\frame.py", line 67, in <module>
from pandas.core.generic import NDFrame, _shared_docs
File "C:\Users\ruhani\Anaconda3\lib\site-packages\pandas\core\generic.py", line 36, in <module>
trainDF=pd.read_csv("C:\\Users\\ruhani\\Desktop\\Minor Project\\projects\\train.csv\\train.csv")
AttributeError: module 'pandas' has no attribute 'read_csv'
Please help me as I am new to Python and Machine Learning.
I am new to python.And i am learning the standard library.
Whenever i run the code below , it always raise the AttributeError...
And it seems like there is something wrong with the import command.
Also , i try to run it on the interactive interpreator,and it works just fine.
The sample code
import tempfile
import os
#temp = tempfile.TemporaryFile()
temp = tempfile.mktemp()
print "tempfile","=>",temp
file = open(temp,"w+b")
file.write("*" * 1000)
file.seek(0)
print len(file.read()),"byte"
file.close()
try:
os.remove(temp)
except OSError:
pass
The error output
Traceback (most recent call last):
File "tempfile.py", line 1, in <module>
import tempfile
File "/home/zhkzyth/codeRep/pytest/tempfile.py", line 5, in <module>
tempfile = tempfile.mktemp()
AttributeError: 'module' object has no attribute 'mktemp'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 66, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python2.7/dist-packages/apport/__init__.py", line 1, in <module>
from apport.report import Report
File "/usr/lib/python2.7/dist-packages/apport/report.py", line 12, in <module>
import subprocess, tempfile, os.path, urllib, re, pwd, grp, os
File "/home/zhkzyth/codeRep/pytest/tempfile.py", line 5, in <module>
tempfile = tempfile.mktemp()
AttributeError: 'module' object has no attribute 'mktemp'
Original exception was:
Traceback (most recent call last):
File "tempfile.py", line 1, in <module>
import tempfile
File "/home/zhkzyth/codeRep/pytest/tempfile.py", line 5, in <module>
tempfile = tempfile.mktemp()
AttributeError: 'module' object has no attribute 'mktemp'
My enviroment
ubuntu12.04
python2.7
Did you name your own file tempfile.py? If so, rename it, delete all your *.pyc files, and try again.
PS: providing the actual text of the error with the traceback would tell us these things.
Trying to access an attribute that does not belong to a class or function in a module raises an AttributeError exception, the attribute might have been deprecated in a later version of the Python interpreter being used. I suggest you check the version of the Python you're running and make sure your dir(module) includes the attribute you're trying to use