我正在尝试使用 Ubuntu 安装 cx_oracle,pip install cx_oracle
但是出现以下错误。还尝试转到 pip 包页面,但似乎没有任何与此包关联的文件:https://pypi.python.org/pypi/cx_Oracle/5.1.2
这是否意味着我必须手动安装该包http://cx-oracle.sourceforge.net和外星人?
Downloading/unpacking cx-Oracle
Downloading cx_Oracle-5.1.2.tar.gz
Exception:
Traceback (most recent call last):
File "/home/develop1/virtualEnv2/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 104, in main
status = self.run(options, args)
File "/home/develop1/virtualEnv2/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/install.py", line 245, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/home/develop1/virtualEnv2/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/req.py", line 985, in prepare_files
self.unpack_url(url, location, self.is_download)
File "/home/develop1/virtualEnv2/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/req.py", line 1109, in unpack_url
retval = unpack_http_url(link, location, self.download_cache, self.download_dir)
File "/home/develop1/virtualEnv2/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/download.py", line 456, in unpack_http_url
unpack_file(temp_location, location, content_type, link)
File "/home/develop1/virtualEnv2/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/util.py", line 494, in unpack_file
untar_file(filename, location)
File "/home/develop1/virtualEnv2/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/util.py", line 418, in untar_file
tar = tarfile.open(filename, mode)
File "/usr/lib/python2.7/tarfile.py", line 1678, in open
return func(name, filemode, fileobj, **kwargs)
File "/usr/lib/python2.7/tarfile.py", line 1729, in gzopen
raise ReadError("not a gzip file")
ReadError: not a gzip file
答案1
自动下载的文件似乎已损坏。这就是为什么ReadError: not a zip file
要安装 cx_Oracle,您还需要 Oracle 的 instantclient。如果您想要一种简单的安装方式,我前段时间准备了一个包。python-cxoracle。
只需复制适用于你的 Ubuntu 版本的文件并将 instantclient 添加到 ld.so.conf
wget https://github.com/ozanturksever/python-cxoracle/archive/master.zip
unzip master.zip
cp -r python-cxoracle-master/12.04/* /
echo "/opt/instantclient_11_2" > /etc/ld.so.conf.d/oracleclient.conf
ldconfig