首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我不能让python3.1与PostgreSQL 9.0一起工作

为什么我不能让python3.1与PostgreSQL 9.0一起工作
EN

Stack Overflow用户
提问于 2010-09-23 00:17:02
回答 2查看 542关注 0票数 1

我正在尝试使用py-postgresql,因为它是我发现的唯一可以与python3一起工作的API。下面是弹出的错误:

代码语言:javascript
复制
>>> import postgresql.driver
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "postgresql/driver/__init__.py", line 9, in <module>
    from .pq3 import Driver
  File "postgresql/driver/pq3.py", line 32, in <module>
    from ..python.socket import SocketFactory
  File "postgresql/python/socket.py", line 10, in <module>
    import ssl
  File "/usr/local/lib/python3.1/ssl.py", line 59, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: No module named _ssl

user@yadayada:~$ python3.1
Python 3.1.2 (r312:79147, Sep 20 2010, 16:47:17) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help("modules")

Please wait a moment while I gather a list of all available modules...

CDROM               bisect              io                  shelve
DLFCN               build_class         itertools           shlex
IN                  builtins            json                shutil
TYPES               cProfile            keyword             signal
__future__          calendar            lib2to3             site
_abcoll             cgi                 linecache           smtpd
_ast                cgitb               locale              smtplib
_bisect             chunk               logging             sndhdr
_codecs             cmath               macpath             socket
_codecs_cn          cmd                 macurl2path         socketserver
_codecs_hk          code                mailbox             spwd
_codecs_iso2022     codecs              mailcap             sqlite3
_codecs_jp          codeop              marshal             sre_compile
_codecs_kr          collections         math                sre_constants
_codecs_tw          colorsys            mimetypes           sre_parse
_collections        compileall          mmap                ssl
_compat_pickle      configparser        modulefinder        stat
_csv                contextlib          multiprocessing     string
_ctypes             copy                netrc               stringprep
_ctypes_test        copyreg             nis                 struct
_dummy_thread       crypt               nntplib             subprocess
_elementtree        csv                 ntpath              sunau
_functools          ctypes              nturl2path          symbol
_heapq              curses              numbers             symtable
_io                 datetime            opcode              sys
_json               dbm                 operator            syslog
_locale             decimal             optparse            tabnanny
_lsprof             difflib             os                  tarfile
_markupbase         dis                 os2emxpath          telnetlib
_md5                distutils           ossaudiodev         tempfile
_multibytecodec     doctest             parser              termios
_multiprocessing    dummy_threading     pdb                 test
_pickle             email               pickle              textwrap
_pyio               encodings           pickletools         this
_random             errno               pipes               threading
_sha1               fcntl               pkgutil             time
_sha256             filecmp             platform            timeit
_sha512             fileinput           plistlib            tkinter
_socket             fnmatch             poplib              token
_sre                formatter           posix               tokenize
_strptime           fractions           posixpath           trace
_struct             ftplib              postgresql          traceback
_symtable           functools           pprint              tty
_testcapi           gc                  profile             turtle
_thread             genericpath         pstats              types
_threading_local    getopt              pty                 unicodedata
_warnings           getpass             pwd                 unittest
_weakref            gettext             py_compile          urllib
_weakrefset         glob                pyclbr              uu
abc                 grp                 pydoc               uuid
aifc                gzip                pydoc_data          warnings
antigravity         hashlib             pyexpat             wave
array               heapq               queue               weakref
ast                 hmac                quopri              webbrowser
asynchat            html                random              wsgiref
asyncore            http                re                  xdrlib
atexit              idlelib             reprlib             xml
audioop             imaplib             resource            xmlrpc
base64              imghdr              rlcompleter         xxsubtype
bdb                 imp                 runpy               zipfile
binascii            importlib           sched               zipimport
binhex              inspect             select              

Enter any module name to get more help.  Or, type "modules spam" to search
for modules whose descriptions contain the word "spam".

>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.1/ssl.py", line 59, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: No module named _ssl
>>> import tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.1/tkinter/__init__.py", line 39, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
>>> import _ctypes
>>> 
EN

回答 2

Stack Overflow用户

发布于 2010-09-23 00:26:01

对我来说很好用:

代码语言:javascript
复制
Python 3.1.1 ...
...
>>> import ssl
>>> import _ssl
>>> ssl, _ssl
(<module 'ssl' ...>, <module '_ssl' ...>)

应该包含在标准库中。检查是否可以导入,例如_tkinter_ctypes

票数 0
EN

Stack Overflow用户

发布于 2012-01-07 17:25:31

你是从源代码构建Python的吗?如果是这样的话,您可能希望检查here;在执行./configure时需要使用--with-ssl标志(ssl_ssl的一种更具pythonic风格的包装器,只有在构建时使用--with-ssl时才会包含它)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3771359

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档