Help installing cx_Oracle

后端 未结 3 1529
小蘑菇
小蘑菇 2020-12-14 02:12

I\'m trying to install the cx_Oracle for Python 2.6, but it is failing. I don\'t know enough about C or MS Vis. Studio\'s compiler to even approach fixing it myself.

<
相关标签:
3条回答
  • 2020-12-14 02:30

    If you use Anaconda Python x64, things are easier:

    conda install -c https://conda.anaconda.org/anaconda cx_oracle
    

    (It will install the right Oracle client)


    If you get the following error:

    [Anaconda2] C:\Users\User>conda install -c https://conda.anaconda.org/anaconda c
    x_oracle
    Using Anaconda Cloud api site https://api.anaconda.org
    Fetching package metadata: ......
    Solving package specifications: .................
    Package plan for installation in environment C:\Anaconda2:
    
    The following NEW packages will be INSTALLED:
    
        cx_oracle:            5.1.2-py27_0
        oracle-instantclient: 11.2.0.4.0-0
    
    The following packages will be UPDATED:
    
        conda:                3.19.1-py27_0 --> 4.0.5-py27_0
        pip:                  8.0.2-py27_0  --> 8.1.1-py27_0
        pyyaml:               3.11-py27_2   --> 3.11-py27_3
        setuptools:           19.6.2-py27_0 --> 20.3-py27_0
        wheel:                0.26.0-py27_1 --> 0.29.0-py27_0
    
    Proceed ([y]/n)? y
    
    Unlinking packages ...
    An unexpected error has occurred, please consider sending the            |   0%
    following traceback to the conda GitHub issue tracker at:
    
        https://github.com/conda/conda/issues
    
    Include the output of the command 'conda info' in your report.
    
    
    Traceback (most recent call last):
      File "C:\Anaconda2\Scripts\conda-script.py", line 4, in <module>
        sys.exit(main())
      File "C:\Anaconda2\lib\site-packages\conda\cli\main.py", line 173, in main
        args_func(args, p)
      File "C:\Anaconda2\lib\site-packages\conda\cli\main.py", line 180, in args_fun
    c
        args.func(args, p)
      File "C:\Anaconda2\lib\site-packages\conda\cli\main_install.py", line 45, in e
    xecute
        install.install(args, parser, 'install')
      File "C:\Anaconda2\lib\site-packages\conda\cli\install.py", line 423, in insta
    ll
        plan.execute_actions(actions, index, verbose=not args.quiet)
      File "C:\Anaconda2\lib\site-packages\conda\plan.py", line 538, in execute_acti
    ons
        inst.execute_instructions(plan, index, verbose)
      File "C:\Anaconda2\lib\site-packages\conda\instructions.py", line 148, in exec
    ute_instructions
        cmd(state, arg)
      File "C:\Anaconda2\lib\site-packages\conda\instructions.py", line 95, in UNLIN
    K_CMD
        install.unlink(state['prefix'], arg)
      File "C:\Anaconda2\lib\site-packages\conda\install.py", line 714, in unlink
        os.unlink(meta_path)
    WindowsError: [Error 5] Access is denied: 'C:\\Anaconda2\\conda-meta\\conda-3.19
    .1-py27_0.json'
    
    [Anaconda2] C:\Users\User>
    

    Try running the Anaconda prompt as admin:

    0 讨论(0)
  • 2020-12-14 02:35

    You also need some type of Oracle client installed on your machine, since cx_Oracle is just a bridge between Python and the Oracle Client. Valid Oracle Clients include a full Oracle installation (like Standard or XE) or the Instant Client

    From the README:

    Please note that an Oracle client (or server) installation is required in order to use cx_Oracle. If you do not require the tools that come with a full client installation, it is recommended to install the Instant Client which is far easier to install.

    I have not installed on Windows before, but you may have to set the ORACLE_HOME environment variable so that cx_Oracle knows where to look.

    0 讨论(0)
  • 2020-12-14 02:50

    Why don't you use a binary package like Windows Installer (Oracle 10g, Python 2.6)?

    See http://cx-oracle.sourceforge.net/ for other binary packages


    Addendum (as requested): you must ensure to use the cx_Oracle that :

    • set ORACLE_HOME if this environment variable doesn't exist (see this Oracle FAQ)
    • python can find oraocci11.dll for Oracle 11g, oraocci10.dll for Oracle 10g or oraclient9.dll for Oracle 9i by adding the folder (should be %ORACLE_HOME%/bin) where the DLL is in you PATH environment variable
    • use the correct binary package (i.e. built for the right Python/Oracle versions)
    0 讨论(0)
提交回复
热议问题