ImportError: cannot import name '_rfc_1738_quote' - sqlalchemy

I am trying to connect Jupyter Notebook to Snowflake but getting the below issue
`
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-12-3b4f5d455df9> in <module>
1 from sqlalchemy import create_engine
----> 2 from snowflake.sqlalchemy import URL
3 import sqlalchemy as db
4 import pandas as pd
5
~\AppData\Local\Continuum\anaconda3\lib\site-packages\snowflake\sqlalchemy\__init__.py in <module>
56 VARIANT,
57 )
---> 58 from .util import _url as URL
59 from .version import VERSION
60
~\AppData\Local\Continuum\anaconda3\lib\site-packages\snowflake\sqlalchemy\util.py in <module>
11 from urllib.parse import quote_plus
12
---> 13 from sqlalchemy.engine.url import _rfc_1738_quote
14
15
ImportError: cannot import name '_rfc_1738_quote'
`
And here: https://github.com/snowflakedb/snowflake-sqlalchemy/issues/350 it was supposed to upgrade to v1.4.3 version but getting the below error when trying to upgrade.
Used command: pip install snowflake-sqlalchemy==1.4.3
Error
`
ERROR: Could not find a version that satisfies the requirement snowflake-sqlalchemy==1.4.3 (from versions: 1.0.7, 1.0.8, 1.0.9, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.1.6, 1.1.9, 1.1.10, 1.1.11, 1.1.12, 1.1.13, 1.1.14, 1.1.15, 1.1.16, 1.1.17, 1.1.18, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.3.3, 1.3.4)
ERROR: No matching distribution found for snowflake-sqlalchemy==1.4.3
`
Can someone please help with the issue?
Tried to upgrade to the latest version which is not the latest.

The issue was resolved by upgrading python to 3.9 and then upgrading sqlalchemy to 1.4.3

Related

AttributeError: module 'keras.api._v2.keras' has no attribute 'utils'

OS: MacOS Monterey (12.4)
Chip: Apple Silicon M1
Env: Conda 4.12.0
Python: 3.9.12
TensorFlow version: 2.9.0, installed through pip install tensorflow-macos
Error message:
Traceback (most recent call last):
File "/Users/okihita/PycharmProjects/TFFlowerClassification/main.py", line 20, in <module>
training_dataset = tf.keras.utils.image_dataset_from_directory(
AttributeError: module 'keras.api._v2.keras' has no attribute 'utils'
Here's my main.py code:
import pathlib
import tensorflow as tf
from PIL import Image
data_dir = pathlib.Path('aksara-batak/toba')
aksara = list(data_dir.glob('a/*'))
img_height = 30
img_width = 30
training_dataset = tf.keras.utils.image_dataset_from_directory(
data_dir,
validation_split=0.2,
subset="training",
seed=123,
image_size=(img_height, img_width)
)
Did I import the wrong version of TensorFlow?

Django 2.0 - Python3.6 - CentOS 7 - MySQL connections

i try to install my website on a webserver which is in CentOS 7 with Django 2.0.6 and Python 3.6.
I installed : mysql-connector = 2.1.6,
mysql-connector-python = 8.0.11,
MySQL-python = 1.2.5,
mysqlclient = 1.3.12,
PyMySQL = 0.8.1
And when i run this command :
python3.6 manage.py migrate
I have this error :
File "MYPYTHONPATH/python3.6/site-packages/django/db/backends/mysql/base.py", line 36, in <module>
raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 1.2.5
But in the base.py file :
try:
import MySQLdb as Database
except ImportError as err:
raise ImproperlyConfigured(
'Error loading MySQLdb module.\n'
'Did you install mysqlclient?'
) from err
from MySQLdb.constants import CLIENT, FIELD_TYPE # isort:skip
from MySQLdb.converters import conversions # isort:skip
# Some of these import MySQLdb, so import them after checking if it's installed.
from .client import DatabaseClient # isort:skip
from .creation import DatabaseCreation # isort:skip
from .features import DatabaseFeatures # isort:skip
from .introspection import DatabaseIntrospection # isort:skip
from .operations import DatabaseOperations # isort:skip
from .schema import DatabaseSchemaEditor # isort:skip
from .validation import DatabaseValidation # isort:skip
version = Database.version_info
if version < (1, 3, 3):
raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)
I dont understand what can i do for resolving this kind of problem !
I hope someone can help me on =)
Okay, i solved it with the answer of this thread.
No module named MySQLdb
pip install PyMySQL
and then add this two lines to your Project/Project/init.py
import pymysql
pymysql.install_as_MySQLdb()
Works on WIN and python 3.3+

Import globally installed module

I am trying to execute my python script which imports globally installed modules through pip. (Module like nltk)
Below is my code.
interpreter.execfile("/home/roy/eclipse-workspace/geospatial-analysis/src/main/resources/wordnet_util.py");
PyObject someFunc = interpreter.get("get_similarity");
PyObject result = someFunc.__call__(new PyString("Apple pie."), new PyString("Banana pie."));
Double realResult = (Double) result.__tojava__(Double.class);
I have added the path for python modules like,
import sys
sys.path.append("/usr/local/lib/python2.7/dist-packages")
But I get the following error,
*sys-package-mgr*: can't create package cache dir, '/usr/local/lib/python2.7/dist-packages/cachedir/packages'
Exception in thread "main" Traceback (most recent call last):
File "/home/roy/eclipse-workspace/geospatial-analysis/src/main/resources/wordnet_util.py", line 6, in <module>
from nltk import word_tokenize, pos_tag
File "/usr/local/lib/python2.7/dist-packages/nltk/__init__.py", line 18, in <module>
from __future__ import print_function, absolute_import
ImportError: No module named __future__
Update:
I added sys.path.append("/usr/lib/python2.7") to the python file. It solved the above error. Now it can't find select module.
ImportError: No module named signal

what's wrong with my keras.using theano backend

i am learning to use deeping learning to deal with physics problem.when i want to run my program by theano,there are some bad things happended.
~$ python
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import theano
Traceback (most recent call last):
File "", line 1, in
File "theano.py", line 1
%!PS-Adobe-3.0
^
SyntaxError: invalid syntax
import keras
Using Theano backend.
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/keras/init.py", line 3, in
from . import utils
File "/usr/local/lib/python2.7/dist-packages/keras/utils/init.py", line 6, in
from . import conv_utils
File "/usr/local/lib/python2.7/dist-packages/keras/utils/conv_utils.py", line 3, in
from .. import backend as K
File "/usr/local/lib/python2.7/dist-packages/keras/backend/init.py", line 80, in
from .theano_backend import *
File "/usr/local/lib/python2.7/dist-packages/keras/backend/theano_backend.py", line 3, in
import theano
File "theano.py", line 1
%!PS-Adobe-3.0
^
SyntaxError: invalid syntax

nltk successfully installed, but now I can't import it

I just installed nltk and now it's not working, and I need assistance figuring out what's wrong.
I followed the install guide here [https://pythonprogramming.net/tokenizing-words-sentences-nltk-tutorial/][1]
Installed via pip
sudo pip install nltk
Then I launched python and downloaded all components
# python3
>>> import nltk
>>> nltk.download()
This worked, and it downloaded all the components(I chose all). After which I figured I was good to go. However, then I went to write my first script and it errored out on the 1st line which imported nltk.
Now when I open the python interpreter I get
# python3
>>> import nltk
"2016-03-02 04:34:03,630","regex.py","ERROR","There is a problem with your SQL query: SELECT regex, regex_id FROM regex WHERE type = 'date'"
Traceback (most recent call last):
File "/home/nick/booze-dev/regex.py", line 10, in <module>
cursor.execute(SQL) # Execute SQL
NameError: name 'cursor' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/nltk/__init__.py", line 128, in <module>
from nltk.chunk import *
File "/usr/local/lib/python3.4/dist-packages/nltk/chunk/__init__.py", line 157, in <module>
from nltk.chunk.api import ChunkParserI
File "/usr/local/lib/python3.4/dist-packages/nltk/chunk/api.py", line 15, in <module>
from nltk.chunk.util import ChunkScore
File "/usr/local/lib/python3.4/dist-packages/nltk/chunk/util.py", line 13, in <module>
from nltk.tag.mapping import map_tag
File "/usr/local/lib/python3.4/dist-packages/nltk/tag/__init__.py", line 63, in <module>
from nltk.tag.sequential import (SequentialBackoffTagger, ContextTagger,
File "/usr/local/lib/python3.4/dist-packages/nltk/tag/sequential.py", line 25, in <module>
from nltk.classify import NaiveBayesClassifier
File "/usr/local/lib/python3.4/dist-packages/nltk/classify/__init__.py", line 98, in <module>
from nltk.classify.textcat import TextCat
File "/usr/local/lib/python3.4/dist-packages/nltk/classify/textcat.py", line 47, in <module>
import regex as re
File "/home/nick/booze-dev/regex.py", line 14, in <module>
sys.exit("Aborting script execution")
NameError: name 'sys' is not defined
I didn't get that error the 1st time I ran the import and executed nltk.download(), so I'm not understanding why I'm getting it now.
I've tried executing python as root and my normal user, and get the same error.
If I check my sys.path
>>> import sys
>>> sys.path
['', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload', '/usr/local/lib/python3.4/dist-packages', '/usr/lib/python3/dist-packages']
I can find nltk under /usr/local/lib/python3.4/dist-packages:
# ls /usr/local/lib/python3.4/dist-packages | grep nltk
nltk
nltk-3.1.egg-info
So it should be available. So why am I getting an error when importing now?