This is my code:
from example1 import db, Puppy
db.create_all()
sam = Puppy('Sammy', 3)
frank = Puppy ('Frankie',2)
print (sam.id)
print (frank.id)
db.session.add_all([sam,frank])
db.session.commit()
print(sam.id)
print(frank.id)
And this is my error:
& C:/Python/Python38/python.exe r:/dinabelajar/Flask-Bootcamp-master/05-Databases/coba/setdatabase.py
Traceback (most recent call last):
File "r:/dinabelajar/Flask-Bootcamp-master/05-Databases/coba/setdatabase.py", line 1, in <module>
from example1 import db, Puppy
File "r:\dinabelajar\Flask-Bootcamp-master\05-Databases\coba\example1.py", line 3, in <module>
from flask_sqlalchemy import SQLAlchemy
File "C:\Python\Python38\lib\site-packages\flask_sqlalchemy\__init__.py", line 22, in <module>
import sqlalchemy
File "C:\Python\Python38\lib\site-packages\sqlalchemy\__init__.py", line 9, in <module>
from .sql import (
File "C:\Python\Python38\lib\site-packages\sqlalchemy\sql\__init__.py", line 8, in <module>
from .expression import (
File "C:\Python\Python38\lib\site-packages\sqlalchemy\sql\expression.py", line 34, in <module>
from .visitors import Visitable
File "C:\Python\Python38\lib\site-packages\sqlalchemy\sql\visitors.py", line 28, in <module>
from .. import util
File "C:\Python\Python38\lib\site-packages\sqlalchemy\util\__init__.py", line 8, in <module>
from .compat import callable, cmp, reduce, \
File "C:\Python\Python38\lib\site-packages\sqlalchemy\util\compat.py", line 172, in <module>
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'
PS R:\dinabelajar\Flask-Bootcamp-master> & C:/Python/Python38/python.exe r:/dinabelajar/Flask-Bootcamp-master/05-Databases/coba/setdatabase.py
Traceback (most recent call last):
File "r:/dinabelajar/Flask-Bootcamp-master/05-Databases/coba/setdatabase.py", line 1, in <module>
from example1 import db, Puppy
File "r:\dinabelajar\Flask-Bootcamp-master\05-Databases\coba\example1.py", line 3, in <module>
from flask_sqlalchemy import SQLAlchemy
File "C:\Python\Python38\lib\site-packages\flask_sqlalchemy\__init__.py", line 22, in <module>
import sqlalchemy
File "C:\Python\Python38\lib\site-packages\sqlalchemy\__init__.py", line 9, in <module>
from .sql import (
File "C:\Python\Python38\lib\site-packages\sqlalchemy\sql\__init__.py", line 8, in <module>
from .expression import (
File "C:\Python\Python38\lib\site-packages\sqlalchemy\sql\expression.py", line 34, in <module>
from .visitors import Visitable
File "C:\Python\Python38\lib\site-packages\sqlalchemy\sql\visitors.py", line 28, in <module>
from .. import util
File "C:\Python\Python38\lib\site-packages\sqlalchemy\util\__init__.py", line 8, in <module>
from .compat import callable, cmp, reduce, \
File "C:\Python\Python38\lib\site-packages\sqlalchemy\util\compat.py", line 172, in <module>
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'
PS R:\dinabelajar\Flask-Bootcamp-master> & C:/Python/Python38/python.exe r:/dinabelajar/Flask-Bootcamp-master/05-Databases/coba/setdatabase.py
Traceback (most recent call last):
File "r:/dinabelajar/Flask-Bootcamp-master/05-Databases/coba/setdatabase.py", line 1, in <module>
from example1 import db, Puppy
File "r:\dinabelajar\Flask-Bootcamp-master\05-Databases\coba\example1.py", line 3, in <module>
from flask_sqlalchemy import SQLAlchemy
File "C:\Python\Python38\lib\site-packages\flask_sqlalchemy\__init__.py", line 22, in <module>
import sqlalchemy
File "C:\Python\Python38\lib\site-packages\sqlalchemy\__init__.py", line 9, in <module>
from .sql import (
File "C:\Python\Python38\lib\site-packages\sqlalchemy\sql\__init__.py", line 8, in <module>
from .expression import (
File "C:\Python\Python38\lib\site-packages\sqlalchemy\sql\expression.py", line 34, in <module>
from .visitors import Visitable
File "C:\Python\Python38\lib\site-packages\sqlalchemy\sql\visitors.py", line 28, in <module>
from .. import util
File "C:\Python\Python38\lib\site-packages\sqlalchemy\util\__init__.py", line 8, in <module>
from .compat import callable, cmp, reduce, \
File "C:\Python\Python38\lib\site-packages\sqlalchemy\util\compat.py", line 172, in <module>
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'
PS R:\dinabelajar\Flask-Bootcamp-master> & C:/Python/Python38/python.exe r:/dinabelajar/Flask-Bootcamp-master/05-Databases/coba/setdatabase.py
Traceback (most recent call last):
File "r:/dinabelajar/Flask-Bootcamp-master/05-Databases/coba/setdatabase.py", line 1, in <module>
from example1 import db, Puppy
File "r:\dinabelajar\Flask-Bootcamp-master\05-Databases\coba\example1.py", line 3, in <module>
from flask_sqlalchemy import SQLAlchemy
File "C:\Python\Python38\lib\site-packages\flask_sqlalchemy\__init__.py", line 22, in <module>
import sqlalchemy
File "C:\Python\Python38\lib\site-packages\sqlalchemy\__init__.py", line 9, in <module>
from .sql import (
File "C:\Python\Python38\lib\site-packages\sqlalchemy\sql\__init__.py", line 8, in <module>
from .expression import (
File "C:\Python\Python38\lib\site-packages\sqlalchemy\sql\expression.py", line 34, in <module>
from .visitors import Visitable
File "C:\Python\Python38\lib\site-packages\sqlalchemy\sql\visitors.py", line 28, in <module>
from .. import util
File "C:\Python\Python38\lib\site-packages\sqlalchemy\util\__init__.py", line 8, in <module>
from .compat import callable, cmp, reduce, \
File "C:\Python\Python38\lib\site-packages\sqlalchemy\util\compat.py", line 172, in <module>
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'
How can i fix this?
you must update SQLAlchemy
pip uninstall SQLAlchemy
pip install SQLAlchemy==1.3.6
change time.clock() to time.perf_counter() in python 3.8
Related
I'm trying to install bamboolib on a virtual env (py 3.6.8) but when I try to import the library on Jupyter lab I get the following error: module 'bamboolib' has no attribute 'plugins'.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\__init__.py", line 85, in <module>
from bamboolib.wrangler import show
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\wrangler.py", line 81, in <module>
from bamboolib.views.suggest_string_manipulation import SuggestStringManipulation
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\views\suggest_string_manipulation.py", line 13, in <module>
from bamboolib.transformation_plugins.string_transformations import (
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\transformation_plugins\__init__.py", line 5, in <module>
from bamboolib.transformation_plugins.bulk_change_datatype import BulkChangeDatatype
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\transformation_plugins\bulk_change_datatype.py", line 9, in <module>
from bamboolib.plugins import TransformationPlugin, DF_OLD, DF_NEW, Singleselect, Text
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\plugins\__init__.py", line 6, in <module>
from bamboolib.plugins._utils import create_plugin_base_class
File "C:\Users\f.surace\py36\lib\site-packages\bamboolib\plugins\_utils.py", line 5, in <module>
import bamboolib.plugins._registry as PluginRegistry
AttributeError: module 'bamboolib' has no attribute 'plugins'
I have model trained on colab and now I want to use that in my centOS7-server like this
import json
from flask import Flask, jsonify, request
import mysql.connector as mariadb
from simpletransformers.ner import NERModel,NERArgs
model = NERModel('bert', './checkpoint-14000', use_cuda= False)
model_args = NERArgs()
model_args.lazy_loading = True
app = Flask(__name__)
#app.route('/sp', methods=['POST'])
def addOne():
try:
prediction = model.predict([json.loads(request.data)['txt']])
return jsonify({'OK': prediction[0][0]})
except Exception as e:
return jsonify({'ERROR': e})
if __name__ == '__main__':
app.run(host='0.0.0.0')
I use python3.9
but I got the ERROR
Traceback (most recent call last):
File "/home/milad/flask/./wsgi.py", line 1, in <module>
from myproject import app
File "/home/milad/flask/./myproject.py", line 4, in <module>
from simpletransformers.ner import NERModel,NERArgs
File "/usr/local/lib/python3.9/site-packages/simpletransformers/ner/__init__.py", line 2, in <module>
from simpletransformers.ner.ner_model import NERModel
File "/usr/local/lib/python3.9/site-packages/simpletransformers/ner/ner_model.py", line 24, in <module>
from simpletransformers.ner.ner_utils import (
File "/usr/local/lib/python3.9/site-packages/simpletransformers/ner/ner_utils.py", line 33, in <module>
from datasets import load_dataset
File "/usr/local/lib/python3.9/site-packages/datasets/__init__.py", line 37, in <module>
from .arrow_dataset import Dataset, concatenate_datasets
File "/usr/local/lib/python3.9/site-packages/datasets/arrow_dataset.py", line 62, in <module>
from .arrow_reader import ArrowReader
File "/usr/local/lib/python3.9/site-packages/datasets/arrow_reader.py", line 29, in <module>
from .download.download_config import DownloadConfig
File "/usr/local/lib/python3.9/site-packages/datasets/download/__init__.py", line 9, in <module>
from .download_manager import DownloadManager, DownloadMode
File "/usr/local/lib/python3.9/site-packages/datasets/download/download_manager.py", line 29, in <module>
from ..utils.file_utils import cached_path, get_from_cache, hash_url_to_filename, is_relative_path, url_or_path_join
File "/usr/local/lib/python3.9/site-packages/datasets/utils/file_utils.py", line 30, in <module>
from .extract import ExtractManager
File "/usr/local/lib/python3.9/site-packages/datasets/utils/extract.py", line 3, in <module>
import lzma
File "/usr/local/lib/python3.9/lzma.py", line 27, in <module>
from _lzma import *
ModuleNotFoundError: No module named '_lzma'
I find my answer in this just look at the Solution
I use python3.6.0 (googletrans3.0). I import googletrans3.0.
Traceback (most recent call last):
File "C:\Python\Python36-32\traduction essai.py", line 3, in <module>
import googletrans
File "C:\Python\Python36-32\lib\site-packages\googletrans\__init__.py", line 6, in <module>
from googletrans.client import Translator
File "C:\Python\Python36-32\lib\site-packages\googletrans\client.py", line 10, in <module>
import httpcore
File "C:\Python\Python36-32\lib\site-packages\httpcore\__init__.py", line 2, in <module>
from ._async.connection_pool import AsyncConnectionPool
File "C:\Python\Python36-32\lib\site-packages\httpcore\_async\connection_pool.py", line 4, in <module>
from .._backends.auto import AsyncLock, AsyncSemaphore, AutoBackend
File "C:\Python\Python36-32\lib\site-packages\httpcore\_backends\auto.py", line 4, in <module>
import sniffio
File "C:\Python\Python36-32\lib\site-packages\sniffio\__init__.py", line 10, in <module>
from ._impl import (
File "C:\Python\Python36-32\lib\site-packages\sniffio\_impl.py", line 1, in <module>
from contextvars import ContextVar
File "C:\Python\Python36-32\lib\site-packages\contextvars\__init__.py", line 4, in <module>
import immutables
File "C:\Python\Python36-32\lib\site-packages\immutables\__init__.py", line 18, in <module>
from ._protocols import MapKeys as MapKeys
File "C:\Python\Python36-32\lib\site-packages\immutables\_protocols.py", line 6, in <module>
from typing import NoReturn
ImportError: cannot import name 'NoReturn'
image
I'm trying to run a python game source I made, but everytime I do "python Login.py" I get this whole traceback:
Traceback (most recent call last):
File "Login.py", line 1, in <module>
from Houdini.HoudiniFactory import HoudiniFactory
File "/var/xsource/Houdini/HoudiniFactory.py", line 18, in <module>
from Houdini.Crumbs import retrieveItemCollection, retrieveRoomCollection, \
File "/var/xsource/Houdini/Crumbs/__init__.py", line 45, in <module>
from Houdini.Crumbs.Room import RoomSchema, RoomCollection
File "/var/xsource/Houdini/Crumbs/Room.py", line 6, in <module>
from Houdini.Handlers.Games.Table import leaveTable
File "/var/xsource/Houdini/Handlers/Games/__init__.py", line 4, in <module>
from Houdini.Handlers.Play.Moderation import cheatBan
File "/var/xsource/Houdini/Handlers/Play/Moderation.py", line 4, in <module>
from Houdini.Data.Penguin import Penguin
File "/var/xsource/Houdini/Data/__init__.py", line 5, in <module>
from alchimia.engine import TwistedEngine
File "/home/ubuntu/.local/lib/python2.7/site-packages/alchimia/__init__.py", line 3, in <module>
from alchimia.strategy import TWISTED_STRATEGY
File "/home/ubuntu/.local/lib/python2.7/site-packages/alchimia/strategy.py", line 3, in <module>
from sqlalchemy.engine.strategies import DefaultEngineStrategy
ImportError: cannot import name DefaultEngineStrategy
If someone knows how to fix this please let me know, thank you so much!
I have python 2.7.9 on OS X (10.11). I have installed tweepy 3.5.0 and simplejson 3.8.1. When i write a program (IDE: textWrangler) for updating status of twitter account (by using tweepy) and run the program using command line it throws error on "import tweepy" in a program. However when i run the same code on python shell, it execute sucessfuly (without any error). Any suggestions or comments?
Traceback (most recent call last):
File "tweepytesting.py", line 1, in <module>
import tweepy
File "build/bdist.macosx-10.6-intel/egg/tweepy/__init__.py", line 14, in <module>
File "build/bdist.macosx-10.6-intel/egg/tweepy/api.py", line 12, in <module>
File "build/bdist.macosx-10.6-intel/egg/tweepy/binder.py", line 11, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/__init__.py", line 27, in <module>
from . import urllib3
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 33, in <module>
from .packages.ssl_match_hostname import CertificateError
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/packages/__init__.py", line 3, in <module>
from . import ssl_match_hostname
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 3, in <module>
from ssl import CertificateError, match_hostname
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 90, in <module>
import textwrap
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py", line 40, in <module>
class TextWrapper:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py", line 82, in TextWrapper
whitespace_trans = string.maketrans(_whitespace, ' ' * len(_whitespace))
AttributeError: 'module' object has no attribute 'maketrans'
If I add this line:
import string; print(string)
just above import tweepy, then the following is printed:
<module 'string' from '/Users/yasirmuhammad/Desktop/learnpython/string.pyc'>