[英]Why I can not make python3.1 working with PostgreSQL 9.0
我正在尝试使用py-postgresql,因为我只找到了想与python3一起使用的API。 下面是弹出的错误:
>>> 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
>>>
对我来说效果很好:
Python 3.1.1 ...
...
>>> import ssl
>>> import _ssl
>>> ssl, _ssl
(<module 'ssl' ...>, <module '_ssl' ...>)
应该包含在标准库中。 检查是否可以导入_tkinter
或_ctypes
。
您是否从源代码构建Python? 如果是这样,您可能想在这里查看 ; 您在执行./configure
时需要使用--with-ssl
标志( ssl
是_ssl
一个更加Python化的包装器,仅当您在构建时使用--with-ssl
时才包括在内)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.