I want to turn my database into sqlite3 for pandas df
I'm using this piece of code:
con = sqlite3.connect('\path\db.db')
df = pd.read_sql('select * from db', con)
Trackback what I got:
Traceback (most recent call last):
df = pd.read_sql('select * from db', con)
File "PATH\pandas\io\sql.py", line 403, in read_sql
pandas_sql = pandasSQL_builder(con)
File "PATH\pandas\io\sql.py", line 578, in pandasSQL_builder
if _is_sqlalchemy_connectable(con):
File "PATH\pandas\io\sql.py", line 43, in _is_sqlalchemy_connectable
import sqlalchemy
File "PATHPython38-32\lib\site-packages\sqlalchemy\__init__.py", line 12, in <module>
from sqlalchemy.sql import (
File "PATHPython38-32\lib\site-packages\sqlalchemy\sql\__init__.py", line 7, in <module>
from sqlalchemy.sql.expression import (
File "PATHPython38-32\lib\site-packages\sqlalchemy\sql\expression.py", line 32, in <module>
from sqlalchemy import util, exc
File "PATHPython38-32\lib\site-packages\sqlalchemy\util\__init__.py", line 7, in <module>
from .compat import callable, cmp, reduce, defaultdict, py25_dict, \
File "PATHPython38-32\lib\site-packages\sqlalchemy\util\compat.py", line 202, in <module>
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'
Is there something wrong with this code? What is the reason for this error?
SQLALchemy 0.7.10 is really really old. Like 6.5 years old. It used time.clock which ...
:1: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
Related
When you typed gibberish input in terminal this always happen:
some#user:~/home/myfolder$ a
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 28, in <module>
from CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
from CommandNotFound.db.db import SqliteDatabase
File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 3, in <module>
import sqlite3
File "/usr/lib/python3.8/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/lib/python3.8/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: /usr/lib/python3.8/lib-dynload/_sqlite3.cpython-38-x86_64-linux-gnu.so: undefined symbol: sqlite3_trace
Does anyone know why this is happening on Ubuntu 20.04?
I saw this question and it is same problem but with no answer
Traceback (most recent call last):
File "F:\test\AI_ChatBot_Python-master\new.py", line 2, in
chatbot = ChatBot(
File "C:\Users\atulk\anaconda3\lib\site-packages\chatterbot\chatterbot.py", line 34, in init
self.storage = utils.initialize_class(storage_adapter, **kwargs)
File "C:\Users\atulk\anaconda3\lib\site-packages\chatterbot\utils.py", line 54, in initialize_class
return Class(*args, **kwargs)
File "C:\Users\atulk\anaconda3\lib\site-packages\chatterbot\storage\sql_storage.py", line 22, in init
from sqlalchemy import create_engine
File "C:\Users\atulk\anaconda3\lib\site-packages\sqlalchemy_init_.py", line 8, in
from . import util as util # noqa
File "C:\Users\atulk\anaconda3\lib\site-packages\sqlalchemy\util_init.py", line 14, in
from ._collections import coerce_generator_arg # noqa
File "C:\Users\atulk\anaconda3\lib\site-packages\sqlalchemy\util_collections.py", line 16, in
from .compat import binary_types
File "C:\Users\atulk\anaconda3\lib\site-packages\sqlalchemy\util\compat.py", line 264, in
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'
Are you sure, that you're running this from Python version <3.8 because time.clock() has been removed in Python 3.8 or you can simply upgrade sqlalchemy which supports perf_counter as replacement.
Python v3.8 changes
sqlalchemy with time perf_counter
sqlalchemy with time.clock
I get the following error when I try to import sentence_transformers in python 3.6.7 and tensorflow==2.3.0. Can someone please help me with this? Seems like it's a bug in the transformers package.
import sentence_transformers
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/__init__.py", line 3, in <module>
from .datasets import SentencesDataset, SentenceLabelDataset, ParallelSentencesDataset
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/__init__.py", line 1, in <module>
from .sampler import *
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/sampler/__init__.py", line 1, in <module>
from .LabelSampler import *
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/sampler/LabelSampler.py", line 6, in <module>
from ...datasets import SentenceLabelDataset
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/SentenceLabelDataset.py", line 8, in <module>
from .. import SentenceTransformer
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/SentenceTransformer.py", line 11, in <module>
import transformers
File "/usr/local/lib/python3.6/site-packages/transformers/__init__.py", line 124, in <module>
from .pipelines import (
File "/usr/local/lib/python3.6/site-packages/transformers/pipelines.py", line 47, in <module>
from .modeling_tf_auto import (
File "/usr/local/lib/python3.6/site-packages/transformers/modeling_tf_auto.py", line 45, in <module>
from .modeling_tf_albert import (
File "/usr/local/lib/python3.6/site-packages/transformers/modeling_tf_albert.py", line 43, in <module>
from .modeling_tf_utils import (
File "/usr/local/lib/python3.6/site-packages/transformers/modeling_tf_utils.py", line 943, in <module>
def get_initializer(initializer_range: float = 0.02) -> tf.initializers.TruncatedNormal:
File "/usr/local/lib64/python3.6/site-packages/tensorflow/python/util/module_wrapper.py", line 194, in __getattr__
attr = getattr(self._tfmw_wrapped_module, name)
AttributeError: module 'tensorflow._api.v1.initializers' has no attribute 'TruncatedNormal'
Try:
initializer = tf.keras.initializers.TruncatedNormal()
or
initializer = tf.compat.v1.keras.initializers.TruncatedNormal()
In tensorflow2.3.0,you can't find 'TruncatedNormal' in module 'tensorflow._api.v1.initializers'.
Maybe this version has removed this attribute.
I was executing a code from the book Think Python in Python 3. The code follows.
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
import urllib.request
conn = urllib.request.urlopen('http://thinkpython.com/secret.html')
for line in conn:
print(line.strip())
When I execute this code in my machine's terminal, I got this following output.
Traceback (most recent call last):
File "secret.py", line 4, in <module>
import urllib.request
File "/usr/lib/python3.6/urllib/request.py", line 84, in <module>
import base64
File "/usr/lib/python3.6/base64.py", line 10, in <module>
import struct
File "/usr/lib/python3.6/struct.py", line 13, in <module>
from _struct import *
ModuleNotFoundError: No module named '_struct'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 12, in <module>
import subprocess, tempfile, os.path, re, pwd, grp, os, time
File "/usr/lib/python3.6/subprocess.py", line 136, in <module>
import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
Original exception was:
Traceback (most recent call last):
File "secret.py", line 4, in <module>
import urllib.request
File "/usr/lib/python3.6/urllib/request.py", line 84, in <module>
import base64
File "/usr/lib/python3.6/base64.py", line 10, in <module>
import struct
File "/usr/lib/python3.6/struct.py", line 13, in <module>
from _struct import *
ModuleNotFoundError: No module named '_struct'
I did this same code in Anaconda, and I got the correct output. Can anybody help me with this problem.
During installing pandas package through command prompt
using statement - pip install pandas
I am getting an error as shown below -
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
import pandas as pd
File "C:\Users\home\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\__init__.py", line 42, in <module>
from pandas.core.api import *
File "C:\Users\home\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\api.py", line 10, in <module>
from pandas.core.groupby.groupby import Grouper
File "C:\Users\home\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\groupby\__init__.py", line 2, in <module>
from pandas.core.groupby.groupby import (
File "C:\Users\home\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\groupby\groupby.py", line 49, in <module>
from pandas.core.frame import DataFrame
File "C:\Users\home\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\frame.py", line 74, in <module>
from pandas.core.series import Series
File "C:\Users\home\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\series.py", line 66, in <module>
import pandas.core.ops as ops
AttributeError: module 'pandas' has no attribute 'core'