In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces what problems pyinstaller packaging cx_Oracle library will encounter, the article introduces in great detail, has a certain reference value, interested friends must read it!
Pyinstaller packaged cx_ Oracle Library problem handling record
1. Download cx_Oracle
Do not use easy_install or pip under windows, as this installation will not synchronize the environment and report an error:
Distutils.errors.DistutilsSetupError: cannot locate Oracle include files in...
So download the cx_Oracle5.3.exe file and install it
Https://files.pythonhosted.org/packages/48/83/15dd03c752d8840ce763bfad5ebd02568f16b2d6709a2b7e6ff97bc3c0f3/cx_Oracle-5.3-11g.win-amd64-py2.7.exe
two。 Download Oracle Instant Client or use a complete database client installation package, version 11.2 or above.
The database client version and python version and number of digits should be the same.
Download address:
64-bit: https://www.oracle.com/technetwork/topics/winx64soft-089540.html
32-bit: http://www.oracle.com/technetwork/topics/winsoft-085727.html
After download, extract to a path, and add the path to the environment variable of the system, name it ORACLE_HOME, and add ORACLE_HOME to path, otherwise an error will be reported.
Cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle
In this directory, you can build a network\ admin folder to store tnsnames.ora and sqlnet.ora or oraaccess.xml files
3. Install the VC environment
Oracle Instant Client libraries requires a VC environment, and matches the corresponding number of bits and version. The corresponding relationship is as follows:
For Instant Client 18 or 12.2 install VS 2013
For Instant Client 12.1 install VS 2010
For Instant Client 11.2 install VS 2005 64-bit or VS 2005 32-bit
4. Solve the problem of Chinese garbled code
4.1 setting environment variables (global, which may have an impact on other Oracle clients)
Computer-> system Properties-> Advanced system Settings-> system Properties / Advanced Tab-> Environment variables-> system variables-> New->
Variable name: NLS_LANG
Variable value: SIMPLIFIED CHINESE_CHINA.ZHS16GBK
4.2 Settings in python environment
Import os
Os.environ ['NLS_LANG'] =' SIMPLIFIED CHINESE_CHINA.UTF8'
# or os.environ ['NLS_LANG'] =' AMERICAN_AMERICA.AL32UTF8'
5. Connect to the database
Import cx_Oracle
Db=cx_Oracle.connect ('system/oracle@10.98.156.148/oral')
Cursor = db.cursor ()
Cursor.execute ("select * from dba_users where user_id=62")
Row = cursor.fetchall ()
Print (row [0])
Db.commit ()
Cursor.close ()
Db.close (
After the above configuration, there is no need to install Oracle on this machine, nor do you need to create a new NETWORK/ADMIN directory to add tnsnames.ora files, let alone move oci.dll to site-packages.
6. Execute error message after packing: cx_oracle_Error object at 0x000
Environment: on win2008r2_x64+py2.7.13_x64
Error message: cx_Oracle.DatabaseError: DPI-1050: Oracle Client library must be at version 11.2
Solution: confirm that the current version is above 11. If so, add Lib and installation path under the installation path to the front of the path variable.
There is no problem for 7.win2008r2 x64 to run the script directly. Run the packaged program to report an error. Unable to locate the program input point ucrtbase.terminate on the dynamic link library api-ma-win-crt-runtime-11-1-0.dll
Resolution steps:
A. Open CMD, enter winver.exe, enter to run, and view the current Windows version
If the version is 7600, first install: windows6.1-KB976932-X64.exe (link), upgrade the version to? 7601:Service Pack 1, and then proceed to step 2
If the version is 7601:Service Pack 1 as shown above, proceed directly to step 2
B. Installation: Microsoft .NET Framework 4.6.1 NDP461-KB3102438-Web.exe (link)
C. Installation: Visual C++ Redistributable for Visual Studio 2015 vc_redist.x64.exe (link)
D. in general, the problem has been solved by step 3, but if you install the software again, there will still be an error "unable to locate the program input point ucrtbase.terminate into the dynamic link library api-ms-win-crt-runtime- | 1-1-0.dll", then you can install the patch: Windows6.1-KB2999226-x64. MSU (link)
8. Error prompt: cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle
If the command line executes this error: copy all the * .dll files in the instantclient directory to the Python27\ Lib\ site-packages directory to solve the problem.
If there is no problem with the execution of the command line of the program, there is no problem for the command line sqlplus to connect directly to the database, but the error is reported after packaging. The solution is as follows
Similar situation on the Internet:
Https://stackoverflow.com/questions/36478831/pyinstaller-cx-oracle-interfaceerror-unable-to-acquire-oracle-environment-hand
The reason for the problem is that pyinstall did not package the oracle link library when it was packaged, resulting in an error report in a different environment.
First pack it normally and generate a spec file, such as
Python-F checkreport.py-I dl.ico
Then edit the checkreport.spec file in the program directory and modify the a.binaries line as follows. Oraociei11.dll must be copied to this directory
A.binaries+ [('oraociei11.dll','oraociei11.dll','BINARY')]
And recompile it.
Pyinstaller checkreport.spec
It works well on other machines after the test.
Information about ODBC on the official website
Https://www.oracle.com/technetwork/database/features/oci/odbc-ic-releasenotes-094306.html
On Windows
Patching the Instant Client ODBC driver on Windows can be done only by manually copying the ODBC driver shared library files and supporting library files from a patched ORACLE_HOME or from an unpacked Oracle Database Bundle patch. These should be copied into the Instant Client directory. Generating an Instant Client ODBC package is not available on Windows.
The files that must be copied to the Instant Client directory:
ODBC driver shared library files: sqora32.dll, sqoras32.dll, sqresus.dll, sqresja.dll
Required additional files when using Oracle Basic Instant Client:
For 12c: oraociei12.dll, orannzsbb12.dll, oci.dll, oraons.dll, ociw32.dll, oraociei12.sym, orannzsbb12.sym, oci.sym, ociw32.sym
For 11g: oraociei11.dll, orannzsbb11.dll, oci.dll, ociw32.dll, oraociei11.sym, orannzsbb11.sym, oci.sym, ociw32.sym
Required additional files when using Oracle Basic Light Instant Client:
For 12c: oraociicus12.dll, orannzsbb12.dll, oci.dll, oraons.dll, ociw32.dll, oraociicus12.sym, orannzsbb12.sym, oci.sym, ociw32.sym
For 11g: oraociicus11.dll, orannzsbb11.dll, oci.dll, ociw32.dll, oraociicus11.sym, orannzsbb11.sym, oci.sym, ociw32.sym
Note: While copying from the Oracle Database Bundle patch, some of the files above may be missing. This implies that those files are unchanged and do not need to be patched.
9. Error report when the package is running: UnicodeDecodeError: 'utf-8' codec can't decode byte
Native environment: win10_x64,anaconda_3 python 3.6.5century x64cxroomoracle 7
There is no problem for the program to run on the command line. After being packaged with pyinstaller, there is no problem for this machine to run. When running on other machines, the error message is as follows.
C:\ Users\ super > D:\ checkreportv1\ checkreportv1\ checkreportp36w10.exe
Traceback (most recent call last):
File "checkreport.py", line 9, in
File "", line 971, in _ find_and_load
File "", line 955, in _ find_and_load_unlocked
File "", line 665, in _ load_unlocked
File "d:\ programdata\ anaconda3\ lib\ site-packages\ PyInstaller\ loader\ pyimod03_importers.py", line 627, in exec_module
File "oradb.py", line 4, in
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb2 in position 53: invalid start byte [6380] Failed to execute script checkreport
Search on the Internet, similar situation
Https://ask.csdn.net/questions/647140?sort=votes_count
Problems encountered in packaging with cx_Oracle modules using Pyinstaller
There is no solution to the problem for the time being. A win2008r2_x64+py2.7.13_x64+cx_Oracle_5.13 environment is found, and the forwarding system executes normally after packaging.
These are all the contents of the article "what will happen to the pyinstaller packaged cx_Oracle Library?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.