Reputation: 135
whenever I use import pg
in my code I get following error
>>> import pg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/site-packages/pg/__init__.py", line 3
async,
^
SyntaxError: invalid syntax
I tried it using pyCharm and terminal directly as well. I am using Python3.9 , import sys; print(sys.version)
output
3.9.1 (default, Dec 29 2020, 08:52:17)
[Clang 12.0.0 (clang-1200.0.32.28)]
My objective is to use connect to redshift. However I am able to use pg8000 but what does this error mean? As per documentation online async
was added after python 3.3 and since I am using 3.9 it should get imported without error
Upvotes: 4
Views: 1859
Reputation: 173
This is happening because you have a 'pg' package installed that is conflicting with the pg module. You may have installed
pip install pg
instead of
pip install PyGreSQL
library. This async keyword issue is from the former. Assuming you dont need the other pg module, delete the pg directory altogether (in your case from /usr/local/lib/python3.9/site-packages/pg) , install the pygresql using the correct pip command if not done already, and try again. you should not get these issues.
Upvotes: 3