I am attempting to do this in a portable version of Django:
from django.db import load_backend
myBackend = load_backend('django.db.backends.oracle') # or 'mysql', 'sqlite3', 'oracle'
However, this results in an error: Error loading cx_Oracle module: No module named cx_Oracle. I assumed this just means that cx_oracle wasn’t installed. When I did a pip install cx_oracle (same as I have for other modules needed), it results in this error:
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
I assume that it is looking for the Oracle client, which I have in place and is in the PATH variable. What else have I over looked, or what is the best way to get Oracle support in a portable version of Django?
You need to modify
LD_LIBRARY_PATHto point to the Oracle client libraries (thelibdirectory) or for Windows – download the appropriate windows binary.