问题
Looking for some help with an issue I am having with psycopg2 and Python3. I am trying to use the sql library from psycopg2 that is available in version 2.7.1. When trying to use
from psycopg2 import sql
I get the error message unresolved reference 'sql'
I am using Xubuntu Linux 16.04 LTS and when issuing the command
pip show psycopg2
in the terminal I get:
Name: psycopg2
Version: 2.7.1
Summary: psycopg2 - Python-PostgreSQL Database Adapter
Home-page: http://initd.org/psycopg/
Author: Federico Di Gregorio
Author-email: fog@initd.org
License: LGPL with exceptions or ZPL
Location: /home/bigdaddy/.local/lib/python3.5/site-packages
Requires:
So it appears to be installed in my system. Also in Pycharm when I go to File -> Settings -> Project Interpreter.. I see psycopg2 2.7.1 installed there as well. Any ideas of what is going on and why I am unable to use the psycopg2 sql functionality in my project? Everything appears to be installed to me it seems. Thanks for any help.
回答1:
That is a common issue in PyCharm, follow those instructions: Unresolved reference issue in PyCharm and you will eliminate the problem!
For the case that the link does not work:
- Right click on your root project folder.
- In the tab that appears, find the Mark Directory as.
- In the expansion window that shows up, click the Sources root
来源:https://stackoverflow.com/questions/43031075/from-psycopg2-import-sql-not-working