我正在尝试在便携式版本的 Django 中执行此操作:
from django.db import load_backend
myBackend = load_backend('django.db.backends.oracle') # or 'mysql', 'sqlite3', 'oracle'
但是,这会导致错误:Error loading cx_Oracle module: No module named cx_Oracle
. 我认为这只是意味着cx_oracle
没有安装。当我做了一个pip install cx_oracle
(与需要的其他模块相同)时,它会导致此错误:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "e:\PortableDjango\development\tools\virtualenvs\test_djangoproj\build\cx-Oracle\setup.py", line 132, in <module>
raise DistutilsSetupError("cannot locate an Oracle software " \
distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "e:\PortableDjango\development\tools\virtualenvs\test_djangoproj\build\cx-Oracle\setup.py", line 132, in <module>
raise DistutilsSetupError("cannot locate an Oracle software " \
distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation
----------------------------------------
Command python setup.py egg_info failed with error code 1 in e:\PortableDjango\development\tools\virtualenvs\test_djangoproj\build\cx-Oracle
Exception information:
Traceback (most recent call last):
File "e:\PortableDjango\development\tools\virtualenvs\test_djangoproj\lib\site-packages\pip-1.1-py2.7.egg\pip\basecommand.py", line 104, in main
status = self.run(options, args)
File "e:\PortableDjango\development\tools\virtualenvs\test_djangoproj\lib\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 "e:\PortableDjango\development\tools\virtualenvs\test_djangoproj\lib\site-packages\pip-1.1-py2.7.egg\pip\req.py", line 1009, in prepare_files
req_to_install.run_egg_info()
File "e:\PortableDjango\development\tools\virtualenvs\test_djangoproj\lib\site-packages\pip-1.1-py2.7.egg\pip\req.py", line 225, in run_egg_info
command_desc='python setup.py egg_info')
File "e:\PortableDjango\development\tools\virtualenvs\test_djangoproj\lib\site-packages\pip-1.1-py2.7.egg\pip\__init__.py", line 256, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in e:\PortableDjango\development\tools\virtualenvs\test_djangoproj\build\cx-Oracle
我假设它正在寻找 Oracle 客户端,该客户端位于 PATH 变量中。我还忽略了什么,或者在可移植版本的 Django 中获得 Oracle 支持的最佳方式是什么?