在cmd中安装CX_ORACLE时出错

时间:2019-01-28 16:57:06

标签: python cx-oracle

当我尝试在Windows 10中通过cmd安装cx_Oracle时,出现以下错误。当我尝试首次安装时,它要求我安装MS Visual C ++ 14并设置PATH,最后显示为命令提示符。

  

由于环境错误而无法安装软件包

C:\Users\Dell>pip install cx_Oracle==5.1.3
Collecting cx_Oracle==5.1.3
  Using cached https://files.pythonhosted.org/packages/be/25/afc07a79ed268f6ab2e8959cfcff997504ce09500b881a1d93f92904762e/cx_Oracle-5.1.3.tar.gz
Error checking for conflicts.
Traceback (most recent call last):
  File "c:\users\dell\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2897, in _dep_map
    return self.__dep_map
  File "c:\users\dell\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2691, in __getattr__
    raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\dell\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2888, in _parsed_pkg_info
    return self._pkg_info
  File "c:\users\dell\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2691, in __getattr__
    raise AttributeError(attr)
AttributeError: _pkg_info

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\dell\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\commands\install.py", line 503, in _warn_about_conflicts
    package_set, _dep_info = check_install_conflicts(to_install)
  File "c:\users\dell\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\operations\check.py", line 108, in check_install_conflicts
    package_set, _ = create_package_set_from_installed()
  File "c:\users\dell\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\operations\check.py", line 47, in create_package_set_from_installed
    package_set[name] = PackageDetails(dist.version, dist.requires())
  File "c:\users\dell\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2635, in requires
    dm = self._dep_map
  File "c:\users\dell\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2899, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "c:\users\dell\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2908, in _compute_dependencies
    for req in self._parsed_pkg_info.get_all('Requires-Dist') or []:
  File "c:\users\dell\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2890, in _parsed_pkg_info
    metadata = self.get_metadata(self.PKG_INFO)
  File "c:\users\dell\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 1410, in get_metadata
    value = self._get(self._fn(self.egg_info, name))
  File "c:\users\dell\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 1522, in _get
    with open(path, 'rb') as stream:
FileNotFoundError: [Errno 2] No such file or directory: 'c:\\users\\dell\\appdata\\local\\programs\\python\\python37-32\\lib\\site-packages\\cx_oracle-7.0.0.dist-info\\METADATA'
Installing collected packages: cx-Oracle
  Found existing installation: cx-oracle 7.0.0
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\users\\dell\\appdata\\local\\programs\\python\\python37-32\\lib\\site-packages\\cx_oracle-7.0.0.dist-info\\RECORD'

我正在安装cx_Oracle以在Django和Oracle数据库之间建立连接。

1 个答案:

答案 0 :(得分:1)

与其安装现在已经很老并且可能无法在Python 3.7上正常运行的cx_Oracle 5.1.3,只需安装cx_Oracle而不指定版本:

pip install cx_Oracle

这应该使您拥有cx_Oracle 7,并且还可以为您提供预编译的二进制文件,因此您也不必担心获得编译器!