简体   繁体   中英

Import pg erroring out in Python3.9

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) 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM