cx_Oracle: distutils.errors.DistutilsSetupError: cannot locate Oracle include files - linux

I need install cx_Oracle for Python 2.5 on Linux (Linux 2.6.18-371.1.2.el5 i686). I have installed Oracle client 10.2.0.4.
I have tried following:
1. Download cx_Oracle tar.gz from http://sourceforge.net/projects/cx-oracle/files/.
I don't know which of listed version are suitable for python 2.5 and Oracle client 10.2.0.4, so try cx_Oracle-5.1.tar.gz. Unpacked tar,
go to unpacked folder and run python setup.py install. I got error:
Traceback (most recent call last):
File "setup.py", line 187, in <module>
raise DistutilsSetupError("cannot locate Oracle include files")
distutils.errors.DistutilsSetupError: cannot locate Oracle include files
In .bash_profile I have setted oracle path:
export ORACLE_HOME=/usr/oracle/10.2.0.4/client
export PATH=$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
How fix such error, maybe I need another version of cx_Oracle tar?
Run pip install cx_Oracle. Got error:
Downloading/unpacking cx-Oracle
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement cx-Oracle
No distributions at all found for cx-Oracle
Could someone advise me right solution?
Update
After suggestion in response I got following error:
...
cx_Oracle.c:496: warning: passing argument 3 of âPyModule_AddIntConstantâ makes integer from pointer without a cast
cx_Oracle.c:497: error: âOCI_UCBTYPE_EXITâ undeclared (first use in this function)
cx_Oracle.c:497: warning: passing argument 3 of âPyModule_AddIntConstantâ makes integer from pointer without a cast
cx_Oracle.c:498: error: âOCI_UCBTYPE_REPLACEâ undeclared (first use in this function)
cx_Oracle.c:498: warning: passing argument 3 of âPyModule_AddIntConstantâ makes integer from pointer without a cast
error: command 'gcc' failed with exit status 1

When you run setup.py it will check for any of these folders on your ORACLE_HOME.
possibleIncludeDirs = ["rdbms/demo", "rdbms/public", "network/public",
"sdk/include"]
Also the instant client sometimes places the include files, such as oci.h, in /usr/include/oracle//client, if there is no 'include' directory under ORACLE_HOME create a symbolic link to it.
sudo ln -s /usr/include/oracle/11.2/client $ORACLE_HOME/include
Looks like you're missing the Client SDK

Make sure you install the instant client sdk for you OS.
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

Install oracle_client_basic
oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
Using pip install
python -m pip install cx_Oracle
Adding ldconfig
Find your client location, for example: /u01/app/oracle/product/11.2.0/client_1/lib
vi /etc/ld.so.conf.d/oracle.conf
Add this location into it:
/u01/app/oracle/product/11.2.0/client_1/lib
ldconfig
import cx_oracle

Make sure that you've a client sdk present in your path.
Also I had to do add this to my .bash_rc
export DYLD_LIBRARY_PATH=$ORACLE_HOME
In addition to this, Python 2.7 does not come with Python.h which is available by default in Python 3.4. So I would also suggest to install python-devel package
yum install python-devel
That should resolve the issue.

Related

Cannot install using pip3 [duplicate]

I recently reinstalled ubuntu and did upgrade to 16.04 and cannot use python:
$ python manage.py runserver
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted
At this point, python itself doesn't work
$ python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted
Even this suggestion is no longer working:
unset PYTHONHOME
unset PYTHONPATH
Every every I fix it one way, it comes back again. Several answers help to fix it temporarily, but not for good. I have reinstalled python and python3 several times. What can I do from here?
For Python-3 try removing virtual environment files. And resetting it up.
rm -rf venv
virtualenv -p /usr/bin/python3 venv/
source venv/bin/activate
pip install -r requirements.txt
https://wiki.ubuntu.com/XenialXerus/ReleaseNotes#Python_3
edit fo
For Windows10 User.
I was using python3.4 on Windows10. I installed python3.5. I couldn't find PYTHONPATH, PYTHONHOME env variable. If I command python in CMD console, It kept using python3.4. I deleted python3.4. Whenever I command python in CMD console, it starts showing an error like below.
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
I searched to figure out my problem. Solution was simple. When you install python3.5, you can custom install and check Add Python to environment variables in Advanced Options.
I just leave here for case that someone have similar issues visit here so that they don't waste their precious time much to figure out.
I was facing the same problem under Windows7. The error message looks like that:
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
Current thread 0x000011f4 (most recent call first):
I have installed python 2.7(uninstalled now), and I checked "Add Python to environment variables in Advanced Options" while installing python 3.6. It comes out that the Environment Variable "PYTHONHOME" and "PYTHONPATH" is still python2.7.
Finally I solved it by modify "PYTHONHOME" to python3.6 install path and remove variable "PYTHONPATH".
For the same issue on Windows7
You will see an error like this if your environment variables/ system variables are incorrectly set:
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'
Current thread 0x00001db4 (most recent call first):
Fixing this is really simple:
When you download Python3.x version, and run the .exe file, it gives you an option to customize where in your system you want to install Python. For example, I chose this location: C:\Program Files\Python36
Then open system properties and go to "Advanced" tab (Or you can simply do this: Go to Start > Search for "environment variables" > Click on "Edit the system environment variables".) Under the "Advanced" tab, look for "Environment Variables" and click it. Another window with name "Environment Variables" will pop up.
Now make sure your user variables have the correct Python path listed in "Path Variable". In my example here, you should see C:\Program Files\Python36. If you do not find it there, add it, by selecting Path Variable field and clicking Edit.
Last step is to double-check PYTHONHOME and PYTHONPATH fields under System Variables in the same window. You should see the same path as described above. If not add it there too.
Then click OK and go back to CMD terminal, and try checking for python. The issue should now be resolved. It worked for me.
I had this error during migration to Ubuntu 17.10, and this solved the problem :
sudo dpkg-reconfigure python3
Maybe you will have to close your session and reconnect.
Look at /lib/python3.5 and you will see broken links to python libraries. Recreate it to working directory.
Next error -
./script/bin/pip3
Failed to import the site module
Traceback (most recent call last):
File "/home/script/script/lib/python3.5/site.py", line 703, in <module>
main()
File "/home/script/script/lib/python3.5/site.py", line 683, in main
paths_in_sys = addsitepackages(paths_in_sys)
File "/home/script/script/lib/python3.5/site.py", line 282, in addsitepackages
addsitedir(sitedir, known_paths)
File "/home/script/script/lib/python3.5/site.py", line 204, in addsitedir
addpackage(sitedir, name, known_paths)
File "/home/script/script/lib/python3.5/site.py", line 173, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "/home/script/script/lib/python3.5/types.py", line 166, in <module>
import functools as _functools
File "/home/script/script/lib/python3.5/functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
File "/home/script/script/lib/python3.5/weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'
fixed like this - https://askubuntu.com/questions/907035/importerror-cannot-import-name-remove-dead-weakref
cd my-virtualenv-directory
virtualenv . --system-site-packages
I had deleted rm -r /usr/lib/python*
dpkg -S '/usr/lib/python3*' | grep encodings
And then found I needed libpython3.10-minimal
sudo apt-get install --reinstall libpython3.10-minimal
I finally ran
sudo apt-get install --reinstall $(dpkg -S '/usr/lib/python3*' | cut -d ':' -f1 | cut -d ',' -f1 | sort | uniq | tr '\n' ' ')
sudo apt-get install --reinstall $(dpkg -S '/usr/lib/python2*' | cut -d ':' -f1 | cut -d ',' -f1 | sort | uniq | tr '\n' ' ')
To re-install all the packages I deleted files for
Had the same problem when updating my mac to macOS Catalina, while using pipenv. Pipenv creates and manages a virtualenv for you, so the earlier suggestion from #Anoop-Malav is the same, just using pipenv to remove the virtual environment based on the current dir and reset it:
pipenv --rm
pipenv shell # recreate a virtual env with your current Pipfile
I was facing this issue "ModuleNotFoundError: No module named 'encodings" after updating to macOS Catalina.
I was having multiple versions of Python installed in my system.
Removing all the python versions(2.7 and 3.7.4) from macOS system and reinstalling the latest python 3.8 worked for me.
To remove a python from macOS, I've followed the instructions from here How to uninstall Python 2.7 on a Mac OS X 10.6.4?
The above link is for python 2.7 and but you can use the same for 3.7 also.
In my case just changing the permissions of anaconda folder worked:
sudo chmod -R u=rwx,g=rx,o=rx /path/to/anaconda
I got this error when try to launch MySql Workbench 8.0 on my macOS Catalina 10.15.3.
I solved this issue by installing Python 3.7 on my system.
I guess in future, when Workbench will have version greater than 8, it will require newer version of Python. Just look at the library path in the error and you will find required version.
I tried everything, deleted PYTHONPATH and PYTHONHOME - the error didn't go away. I had overlooked that I had specified a python-home path under WSGIDaemonProcess in the wsgi configuration of a VirtualHost. I removed that and the error was gone.
I had a similar issue. I had both anaconda and python installed on my computer and my python dependencies were from the Anaconda directory. When I uninstalled Anaconda, this error started popping. I added PYTHONPATH but it still didn't go.
I checked with python -version and go to know that it was still taking the anaconda path.
I had to manually delete Anaconda3 directory and after that python started taking dependencies from PYTHONPATH.
Issue Solved!
Because this is the first result in google I just want to add the following information for anybody else having problems with jails:
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f079b16d740 (most recent call first):
Aborted (core dumped)
When attempting to import python into your jail you both need to link the dependencies and /usr/lib/pythonX.Y to [JAIL]/usr/lib/. Hope this helps.
I was facing same issue on a Debian server and for me the problem was that I've put my project inside the /root/ folder for which mod_wsgi didn't have the rights to access. So I simply moved my project into /var/www/html/ and update my VirtualHost configuration.
In my case, what worked was the following: I changed the env path in the conf from /home/vinzee/.pyenv/versions/envname/bin/ to /home/vinzee/.pyenv/versions/envname/ and it worked.
It seems the environment path needs to be the path to the root folder of the virtual environment (and not the path to ROOT_VENV/bin/).
You can additionally try without the trailing slash as others have suggested, but in my case, it worked both with and without it.
It seems this error can happen for a large variety of reasons (given the number of different answers on here).
For me, the issue was related to the fact that my app was deployed in a virtualenv, and the pyvenv.cfg file had the wrong permissions. It must be writable by the user uwsgi is running as (which in my case was http).
Just go to File -> Settings -> select Project Interpreter under Project tab -> click on the small gear icon -> Add -> System Interpreter -> select the python version you want in the drop down menu
this seemed to work for me
I could also fix this. PYTHONPATH and PYTHONHOME were in cause.
run this in a terminal
touch ~/.bash_profile
open ~/.bash_profile
and then delete all useless parts of this file, and save.
I do not know how recommended it is to do that !

informix DB with RobotFramework

I am trying to connect to informix DB from Robotframework script running on Mac. I have installed Robotframework-Database-Library[1.0.1] from http://franz-see.github.io/Robotframework-Database-Library/.
tried to install Informix DB per https://wiki.python.org/moin/Informix. Ran into issue
error: Can't find esql. Please set INFORMIXDIR correctly.
tried to install mxODBC using python. still running into error
I have installed egenix-mx-base-3.2.9-py2.7_ucs2-macosx-10.5-x86_64-prebuilt as this is precondition. Tried to verify the mx-base using.
$ pip install egenix-mx-base
Requirement already satisfied: egenix-mx-base in /Library/Python/2.7/site-packages.
Then tried to install egenix-mxodbc-3.3.6-py2.7_ucs2-macosx-10.4-fat-prebuilt.
msuresh$ python setup.py install
running install
found usable build data file 'build/build-py2.7_ucs2.pck'
prebuilt archive found: skipping the build process and loading the prebuilt archive
setting platform to 'macosx-10.4-fat'
adjusting distutils platform string from 'macosx-10.13-x86_64' to 'macosx-10.4-fat'
restoring build data from a previous build run
loaded build data for platform 'macosx-10.4-fat'
running install_lib
writing byte-compilation script '/var/folders/dc/nwlkjl0129d3qm1j8m5czmgsnkqkf_/T/tmpRNEu3H.py'
/usr/local/opt/python#2/bin/python2.7 -O /var/folders/dc/nwlkjl0129d3qm1j8m5czmgsnkqkf_/T/tmpRNEu3H.py
removing /var/folders/dc/nwlkjl0129d3qm1j8m5czmgsnkqkf_/T/tmpRNEu3H.py
running install_data
running install_egg_info
Removing /usr/local/lib/python2.7/site-packages/egenix_mxodbc-3.3.6-py2.7.egg-info
Writing /usr/local/lib/python2.7/site-packages/egenix_mxodbc-3.3.6-py2.7.egg-info
But on trying to verify mxodbc --> does through me error.
>>> import mx.ODBC.Manager
Traceback (most recent call last):
File "", line 1, in
File "mx/ODBC/Manager/__init__.py", line 48, in
ImportError: None of the supported ODBC managers unixODBC, iODBC or DataDirect could be imported: dlopen(/usr/local/lib/python2.7/site-packages/mx/ODBC/unixODBC/mxODBC.so, 2): no suitable image found. Did find:
/usr/local/lib/python2.7/site-packages/mx/ODBC/unixODBC/mxODBC.so: no matching architecture in universal wrapper
/usr/local/lib/python2.7/site-packages/mx/ODBC/unixODBC/mxODBC.so: no matching architecture in universal wrapper, dlopen(/usr/local/lib/python2.7/site-packages/mx/ODBC/iODBC/mxODBC.so, 2): no suitable image found. Did find:
/usr/local/lib/python2.7/site-packages/mx/ODBC/iODBC/mxODBC.so: no matching architecture in universal wrapper
/usr/local/lib/python2.7/site-packages/mx/ODBC/iODBC/mxODBC.so: no matching architecture in universal wrapper, No module named DataDirect
.. Any help to get informix connection via Robotframework would be appreciated.
It sounds like you need to download and install the Informix Client SDK from here

python-escpos windows giving "bugtrack_url" error

Trying to install python-escpos library. The instructions say the following:
Ensure the library is installed on ${lib_arch}/${python_ver}/site-packages/escpos
On CLi you must run:
python setup.py build
sudo python setup.py install
What does ${lib_arch}/${python_ver}/ mean? Is it the path such as
\Users\RickT\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\escpos?
When I run python setup.py build, I get the following error:
C:\Users\RickT\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py:261: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg)Traceback (most recent call last):
File "setup.py", line 140, in <module> 'python-escpos = escpos.cli:main'
As I wrote in the comments you should write which version of the documentation you are using and which version of the codebase you are using.
The "error" considering the bugtrack_url is just a warning because setuptools does not know this token. This should not affect your setup in any way. You probably installed it successfully.
Concerning your question about the path: ${lib_arch}/${python_ver}/site-packages/escpos is more or less non-sense in a Windows-context. This just means your location of the site-packages-directory. So, your assumption is right.
All in all the probably easiest solution for you would be installing with pip. This would simply be - considering you have a working pip - a one-liner:
pip install python-escpos

Cannot install NumPy from a wheel format

I am trying to install NumPy from a wheel (.whl) file. I get the error:
numpy-1.9.1%2Bmkl-cp34-none-win_amd64.whl is not a supported wheel on this platform.
Details:
Windows 8.1 pro x64, elevated command prompt
Python 3.4.2
Package NumPy from Gohlke's site
File numpy-1.9.1%2Bmkl-cp34-none-win_amd64.whl copied in the pip.exe folder
The log file shows:
d:\Program Files\WinPython-64bit-3.4.2.4\python-3.4.2.amd64\Scripts\pip run on 01/23/15 11:55:21
numpy-1.9.1%2Bmkl-cp34-none-win_amd64.whl is not a supported wheel on this platform.
Exception information:
Traceback (most recent call last):
File "D:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "D:\Python34\lib\site-packages\pip\commands\install.py", line 257, in run
InstallRequirement.from_line(name, None))
File "D:\Python34\lib\site-packages\pip\req.py", line 167, in from_line
raise UnsupportedWheel("%s is not a supported wheel on this platform." % wheel.filename)
pip.exceptions.UnsupportedWheel: numpy-1.9.1%2Bmkl-cp34-none-win_amd64.whl is not a supported wheel on this platform.
What is wrong?
Short answer: rename the file to numpy-1.9.1%2Bmkl-cp34-none-win32.whl to install it.
You can check what tags your pip tool accepts for installation by running:
import pip; print(pip.pep425tags.get_supported())
In this case pip is incorrectly detecting your operating system to be 32-bits and the file you're trying to install was win_amd64 in its filename.
If you rename the file to numpy-1.9.1%2Bmkl-cp34-none-win32.whl (which now contains the tags that are considered supported) then you can install the package. It's a trick because the file is still built for 64-bits but this allows you to install the package as intended.
After several tests I think the problem is "win32" or "amd64" itself. I tried replacing those two with "any" and it worked.
In my case, the workaround to install gohlke packages on Python (3.4.4 (AMD64)) was to change the "cp34m" part rather than the "win*" parts in previous answers:
python -c "import pip; print(pip.pep425tags.get_supported())":
[('cp34', 'none', 'win_amd64'), ('py3', 'none', 'win_amd64'),
('cp34', 'none', 'any'), ...
ls -ld *:
matplotlib-2.0.0b3-cp34-cp34m-win_amd64.whl
numpy-1.11.1+mkl-cp34-cp34m-win_amd64.whl
pandas-0.18.1-cp34-cp34m-win_amd64.whl
Change the above names to:
matplotlib-2.0.0b3-cp34-none-win_amd64.whl
numpy-1.11.1+mkl-cp34-none-win_amd64.whl
pandas-0.18.1-cp34-none-win_amd64.whl
For example, pip install matplotlib-2.0.0b3-cp34-none-win_amd64.whl
Processing ...
...Successfully installed matplotlib-2.0.0b3
To add to the list of other possible solutions, I had to upgrade pip itself. The latest binary from Gholke's site had the "cp27m" tag, which didn't show up when I checked the pip tags using:
import pip; print(pip.pep425tags.get_supported())
After I upgraded pip, the wheel didn't work, but just doing a regular pip install numpy worked.
If you have, say, Python 3.4 installed, make sure to install the -cp34- version of the wheel and not -cp35-.
The current WinPython package manager need a two-characters fix to accept to recognize the new NumPy + mkl 'wheel'.
https://github.com/stonebig/winpython/commit/5e13230609a2e9f4d66d98c3776207ce4b4dd050
As a workaround, uninstall the NumPy package:
pip uninstall numpy
Then install it again from cache:
pip install numpy
I had the same problem with several packages after upgrading from 3.4.1 to 3.4.2.
Navigate to the directory where your 'pip.py' sits and then type following on the Windows command line:
..\python.exe pip.py install name_of_package.whl
This should work.
I had the same problem and tried to work it out with the suggested solutions.
I changed win64 to win32 and it didn't work either. But then I changed the name to original and this time it worked! The only extra thing I did was to go offline. That's so strange.
This has nothing to do with your operating system. Uninstall Python 32-bit and install Python 64-bit rather or alternatively find a 32-bit wheel file.

psycopg2 import error due to failure to load libraries

I have tried many ways of installing psycopg2 after having installed PostgreSQL using the one-click installer, but anyway I try confronts me with the same import error in python: ImportError: dlopen(/Library/Python/2.5/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: libpq.5.dylib
Referenced from: /Library/Python/2.5/site-packages/psycopg2/_psycopg.so
Reason: image not found
I am on Mac OS X 10.5.8. I am using Python 2.5. I installed PostgreSQL from the installer (I did not port it) and it installed in /Library). I added /Library/PostgreSQL/9.1/bin to the setup.cfg of the source psycopg2, as instructed in the INSTALL file and everywhere on the internet and then ran sudo python setup.py build and then sudo python setup.py install.
I also tried exporting /Library/PostgreSQL/9.1/bin to my path instead and running sudo pip install psycopg2. But the exact same problem occurred in all of these scenarii.
I would greatly appreciate some help with this.
Best
Marion
The problem is that at runtime the libpq.5.dylib file can't be found because it is not in one of the default locations searched by the dynamic (runtime) linker. Try to define the environment variable DYLD_LIBRARY_PATH before launching python. I am no MacOS X expert but something like:
export DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.1/lib
will probably work.

Resources