Freebsd
在 virtualenv 中的 FreeBSD 上的 pysqlite 安裝錯誤
我正在嘗試在 FreeBSD 7.3 的 virtualenv 下使用 pip 安裝 pysqlite,Python 版本為 2.6.2。我在安裝 Django、PIL 等其他軟體包時沒有任何問題。我只在啟動 virtualenv 後安裝了所有這些軟體包。但我得到一個巨大的錯誤
pip install sqlite
。這是錯誤的尾巴src/module.c:426: warning: implicit declaration of function 'sqlite3_libversion' src/module.c:426: warning: passing argument 1 of 'PyString_FromString' makes pointer from integer without a cast error: command 'gcc' failed with exit status 1 Command /usr/home/myuser/python-sites/virtpython/bin/python -c "import setuptools;__file__='/usr/home/myuser/python-sites/virtpython/build/pysqlite/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /usr/tmp/pip-N3U6Px-record/install-record.txt --single-version-externally-managed --install-headers /usr/home/myuser/python-sites/virtpython/include/site/python2.6 failed with error code 1 in /usr/home/myuser/python-sites/virtpython/build/pysqlite Exception information: Traceback (most recent call last): File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/basecommand.py", line 107, in main status = self.run(options, args) File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/commands/install.py", line 261, in run requirement_set.install(install_options, global_options) File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/req.py", line 1166, in install requirement.install(install_options, global_options) File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/req.py", line 589, in install cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False) File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/util.py", line 612, in call_subprocess % (command_desc, proc.returncode, cwd)) InstallationError: Command /usr/home/myuser/python-sites/virtpython/bin/python -c "import setuptools;__file__='/usr/home/myuser/python-sites/virtpython/build/pysqlite/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /usr/tmp/pip-N3U6Px-record/install-record.txt --single-version-externally-managed --install-headers /usr/home/myuser/python-sites/virtpython/include/site/python2.6 failed with error code 1 in /usr/home/myuser/python-sites/virtpython/build/pysqlite
‘virtpython’ 是我的虛擬環境
% pkg_info | grep sqlite sqlite-2.8.17_1 An SQL database engine in a C library sqlite3-3.6.11 An SQL database engine in a C library
如果有適用於 FreeBSD 的 sqlite 開發包,我在哪裡可以找到它?還是問題是別的??
我也遇到過類似的問題,我找到的唯一解決辦法是進入pip build dir(/tmp/pip-{random hash},一般可以在報錯的尾部找到,也可以是 /usr/tmp/,或命名為 pysqlite,取決於您的設置)並更改 pysqlite setup.cfg。下載後是這樣的:
[build_ext] #define= #include_dirs=/usr/local/include #library_dirs=/usr/local/lib libraries=sqlite3 define=SQLITE_OMIT_LOAD_EXTENSION
當我取消註釋 include_dirs 和 library_dirs 時,pysqlite 將安裝得很好。這樣做的缺點是我還沒有找到一種方法來輕鬆地自動執行此步驟,因此需要在每個 virtualenv 設置中完成。這很醜陋,令人不快,而且很痛苦,但它確實可以安裝 pysqlite。
希望這可以幫助。
PS 如果您嘗試在 virtualenv 中執行 pip 安裝,下載的文件很可能在 {virtualenv}/build/pysqlite 中找到。