2010-09-22 6 views
1

J'essaie d'utiliser py-postgresql, car c'est seulement l'API que j'ai trouvé qui est supposée fonctionner avec python3. Toute suggestion ou aide est la bienvenue. Ci-dessous est l'erreur d'apparaître:Pourquoi je ne peux pas faire fonctionner python3.1 avec posgresql 9.0

>>> 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 

[email protected]:~$ 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 
>>> 

Répondre

0

fonctionne bien pour moi:

Python 3.1.1 ... 
... 
>>> import ssl 
>>> import _ssl 
>>> ssl, _ssl 
(<module 'ssl' ...>, <module '_ssl' ...>) 

devrait être inclus dans la bibliothèque standard. Vérifiez si vous pouvez importer par ex. _tkinter ou _ctypes.

+0

Je peux voir sll dans les modules installés mais je ne peux pas l'importer, de même avec tkinter. Il n'y a aucun problème à importer des ctypes. – Giorgi

0

Avez-vous construit Python à partir de la source? Si oui, vous pouvez vérifier here; vous devez utiliser le drapeau --with-ssl lorsque vous faites ./configure (ssl est un wrapper plus pythonique autour de _ssl, qui est seulement inclus si vous utilisez --with-ssl lorsque vous construisez).

Questions connexes