From psycopg2 import sql not working

回眸只為那壹抹淺笑 提交于 2021-01-29 04:44:25

问题


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:

  1. Right click on your root project folder.
  2. In the tab that appears, find the Mark Directory as.
  3. In the expansion window that shows up, click the Sources root


来源:https://stackoverflow.com/questions/43031075/from-psycopg2-import-sql-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!