我正在尝试使用py-postgresql,因为它只是我发现的API,它假设与python3一起使用。以下是弹出错误:
>>> 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
>>>
答案 0 :(得分:0)
对我来说很好:
Python 3.1.1 ...
...
>>> import ssl
>>> import _ssl
>>> ssl, _ssl
(<module 'ssl' ...>, <module '_ssl' ...>)
应包含在标准库中。检查您是否可以导入例如_tkinter
或_ctypes
。
答案 1 :(得分:0)
您是否从源代码构建了Python?如果是这样,您可以查看here;在--with-ssl
./configure
时,您需要使用ssl
标记_ssl
是--with-ssl
周围更加pythonic的包装,仅当您使用{{1}}时才会包含此标记你建立)。