2017-01-03 6 views
3

sqliteのは、Python 2.7で正常に動作してpythonでインポートすることはできていませんが、私はPythonでこれをインポートしようとしていたときに3それは私が再インストールしようとしています。このエラーを削除するには、エラーにsqlite3のは3

> Traceback (most recent call last): File "dbConnection.py", line 1, 
> in <module> 
>  import sqlite3 File "/usr/local/lib/python3.4/sqlite3/__init__.py", line 23, in <module> 
>  from sqlite3.dbapi2 import * File "/usr/local/lib/python3.4/sqlite3/dbapi2.py", line 27, in <module> 
>  from _sqlite3 import * ImportError: No module named '_sqlite3' 

を与えますsqlite3 by

sudo apt-get install sqlite3 

しかし、それは既にパッケージが存在すると言います。その後、私は

pip3 install sqlite3 

してインストールしようとしていますが、再び取り付けている間にエラーに

Collecting sqlite3 
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/sqlite3/ 
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/sqlite3/ 
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb5ff3bc550>, 'Connection to 196.1.114.80 timed out. (connect timeout=15)')': /simple/sqlite3/ 
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/sqlite3/ 
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/sqlite3/ 
Could not find a version that satisfies the requirement sqlite3 (from versions:) 
No matching distribution found for sqlite3 

を与えますが、私の接続が正常に動作している...私はできる午前よう は今、私は何をすべきpython 3でsqlite3をインポートするには?

答えて

1

sqlite3は、オプションの標準ライブラリの一部です。これはPython 3をコンパイルしてインストールするときにコンパイルされますが、右のファイル(開発ヘッダー)が利用可能な場合はsqlite3になります。

あなたはコンパイルとPython 3を自分でインストールした場合は、(例えば、Linuxディストリビューションに依存libsqlite3-devまたはsqlite-develまたは類似の)依存関係をインストールし、次に再コンパイルおよび再インストールのPython 3

外部的には、ライブラリはpysqliteとして維持されます。しかし、that release doesn't support Python 3。それでもインストールするには、まだsqliteの開発ファイルが必要です。Python 3に移植する必要があります。ちょうどPython 3を再コンパイルしてもかまいません。

+0

私はUbuntu 16.04を使用しています。いくつかのサイトで提案されているようにlibsqlite3-devをインストールしました... :( –

+0

コンパイル中にエラーが発生しました: ***警告:「_sqlite3」の読み込みに失敗しました。build/lib.linux-x86_64-3.6/_sqlite3.cpython-36m-x86_64-linux-gnu.so:未定義シンボル:sqlite3_stmt_readonly https://github.com/ghaering/pysqlite/issues/85より、古いsqliteバージョンが原因である可能性があります。 –

関連する問題