问题描述
寻求帮助解决我在使用 psycopg2 和 Python3 时遇到的问题.我正在尝试使用 2.7.1 版中可用的 psycopg2 中的 sql 库.尝试使用时
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
我收到错误消息 unresolved reference 'sql'
I get the error message unresolved reference 'sql'
我正在使用 Xubuntu Linux 16.04 LTS 并且在发出命令时
I am using Xubuntu Linux 16.04 LTS and when issuing the command
pip show psycopg2
在终端中我得到:
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:
所以它似乎安装在我的系统中.当我去的时候也在 Pycharm文件 -> 设置 -> 项目解释器..我看到那里也安装了 psycopg2 2.7.1.关于发生了什么以及为什么我无法在我的项目中使用 psycopg2 sql 功能的任何想法?在我看来,一切似乎都已安装.感谢您的帮助.
So it appears to be installed in my system. Also in Pycharm when I go toFile -> 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.
推荐答案
这是 PyCharm 中的常见问题,请按照以下说明操作:PyCharm 中未解决的参考问题,您将解决问题!
That is a common issue in PyCharm, follow those instructions: Unresolved reference issue in PyCharm and you will eliminate the problem!
对于链接失效的情况:
- 右键单击您的根项目文件夹.
- 在出现的选项卡中,找到将目录标记为.
- 在出现的扩展窗口中,单击Sources root
这篇关于从 psycopg2 导入 sql 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!