NoSuchModuleError: unable to load plugin: sqlalchemy.dialects: redshift.psycopg2

I am trying to connect to redshift from my python code. my pip is installed:

psycopg2==2.6.1 redshift-sqlalchemy==0.4.1 SQLAlchemy==1.0.9 

and my virtual machine:

 libpq-dev python-psycopg2 

But I still get

  engine = create_engine('redshift+psycopg2://{}:{}@{}'.format(username, password, url)) File "/opt/project/env/local/lib/python2.7/site-packages/sqlalchemy/engine/__init__.py", line 386, in create_engine return strategy.create(*args, **kwargs) File "/opt/project/env/local/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 51, in create entrypoint = u._get_entrypoint() File "/opt/project/env/local/lib/python2.7/site-packages/sqlalchemy/engine/url.py", line 131, in _get_entrypoint cls = registry.load(name) File "/opt/project/env/local/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 205, in load (self.group, name)) NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:redshift.psycopg2 

With the same configuration, I can work from my laptop (mac), but on linux I assume that some packages are still missing? Any suggestion would be appreciated, thanks!

+5
source share
3 answers

Another way to get a NoSuchModule exception is that the db connection string is in the wrong format. In my case, I got this error when I changed

 DB_URI = 'postgresql://...' 

to

 DB_URI = 'pg8000://...' 

but should be:

 DB_URI = 'postgresql+pg8000:// 
+1
source

The following link helps connect to Redshift via Pythong using the psycopg2 library without SQL alchemy dependency

http://sobhan06k.blogspot.in/2014/11/reach-redshift-using-python-library.html

0
source

I had the same problem and solved it when I deleted the __pycache__ directory in the redshift_sqlalchemy package.

Come on to you, the package sites in my case are in my virtualenv.

so cdvirtualenv and cd lib/python3.5/site-packages/redshift_sqlalchemy finally rm __pycache__ .

0
source

Source: https://habr.com/ru/post/1236282/


All Articles