2013-08-16 87 views
2

我使用Python 2.7(32位)和我的操作系統是64位Windows 7cx_Oracle模塊安裝錯誤消息

我試圖安裝cx_Oracle模塊。我運行了msi「cx_Oracle-5.1.2-10g.win32-py2.7.msi」,然後我在cmd行運行「easy_install cx_Oracle」,並得到以下消息:

錯誤:無法找到vcvarsall .BAT

我在這個網站,最好的解決辦法是安裝Microsoft Visual Studio 2008中,這是我從一個鏈接我在此網站上發現沒發現。

現在,當我運行CMD線我得到以下信息,我不知道這意味着什麼「的easy_install cx_Oracle」:

C:\Python27>easy_install cx_Oracle Searching for cx-Oracle Reading ....org/simple/cx_Oracle/ Reading ....net/crew/atuining Reading ...sourceforge.net Best match: cx-Oracle 5.1.2 Downloading http://prdownloads.sourceforge.net/cx-oracle/cx_Oracle-5.1.2.tar.gz ? download Processing cx_Oracle-5.1.2.tar.gz Writing c:\users\cnielsen\appdata\local\temp\easy_install-44rupd\cx_Oracle-5.1.2 \setup.cfg Running cx_Oracle-5.1.2\setup.py -q bdist_egg --dist-dir c:\users\cnielsen\appda ta\local\temp\easy_install-44rupd\cx_Oracle-5.1.2\egg-dist-tmp-eyihnb Traceback (most recent call last): File "C:\Python27\Scripts\easy_install-script.py", line 9, in load_entry_point('setuptools==0.8', 'console_scripts', 'easy_install')() File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1992 , in main File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1979 , in with_ei_usage File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1996 , in File "C:\Python27\lib\distutils\core.py", line 152, in setup dist.run_commands() File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands self.run_command(cmd) File "C:\Python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 380, in run File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 623, in easy_install File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 653, in install_item File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 849, in install_eggs File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1130 , in build_and_install File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1115 , in run_setup File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 69, in run_setup File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 120, in run File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 71, in File "setup.py", line 350, in File "C:\Python27\lib\distutils\core.py", line 152, in setup dist.run_commands() File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands self.run_command(cmd) File "C:\Python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "build\bdist.win-amd64\egg\setuptools\command\bdist_egg.py", line 185, in run File "build\bdist.win-amd64\egg\setuptools\command\bdist_egg.py", line 171, in call_command File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command self.distribution.run_command(command) File "C:\Python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "build\bdist.win-amd64\egg\setuptools\command\install_lib.py", line 20, i n run File "C:\Python27\lib\distutils\command\install_lib.py", line 111, in build self.run_command('build_ext') File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command self.distribution.run_command(command) File "C:\Python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "build\bdist.win-amd64\egg\setuptools\command\build_ext.py", line 52, in run File "C:\Python27\lib\distutils\command\build_ext.py", line 339, in run self.build_extensions() File "C:\Python27\lib\distutils\command\build_ext.py", line 448, in build_exte nsions self.build_extension(ext) File "build\bdist.win-amd64\egg\setuptools\command\build_ext.py", line 186, in build_extension File "C:\Python27\lib\distutils\command\build_ext.py", line 498, in build_exte nsion depends=ext.depends) File "C:\Python27\lib\distutils\msvc9compiler.py", line 473, in compile self.initialize() File "C:\Python27\lib\distutils\msvc9compiler.py", line 383, in initialize vc_env = query_vcvarsall(VERSION, plat_spec) File "C:\Python27\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsal l raise ValueError(str(list(result.keys()))) ValueError: [u'path']

回答

0

搜索後3天,我終於解決了這個問題。

訣竅是:

  1. 安裝vcredist_x86.exe。 安裝此之後,我跑easy_install cx_Oracle,不再看到原始的錯誤消息。
  2. 重新安裝Python 2.7.5,確保它是32位版本(x86)的
  3. 重新安裝IDE 「PyScripter」,確保它是32位版本(x86)的
+0

順便說一句:我用的vcredist_x86.exe被找到了這裏:http://www.microsoft.com/en-us/download/confirmation.aspx?id=29 –

0

的easy_install的步驟嘗試編譯在cx_Oracle源的機器,但這不是必需的,因爲您已經安裝了MSI,它是一個預編譯的二進制版本。

您所安裝的MSI應該足夠使用cx_Oracle,只要你有二進制Oracle客戶端安裝好了(例如,instantclient)。

+0

謝謝。我無法弄清楚如何安裝Oracle即時客戶端,因爲沒有msi,但我下載了它並將其路徑添加到ENV PATH。然後我重新安裝了Python 2.7 32位。現在我似乎有了cx_Oracle模塊,但是當我嘗試在Python腳本中調用模塊時,我收到了這條新消息:...將cx_Oracle導入爲oracle文件「build \ bdist.win32 \ egg \ cx_Oracle.py」,行7,在文件「build \ bdist.win32 \ egg \ cx_Oracle.py」,第6行,在__bootstrap__ ImportError:DLL加載失敗:%1不是有效的Win32應用程序。 >>> –

+0

有幫助... http://stackoverflow.com/questions/20159566/cx-oracle-importerror-dll-load-failed-this-application-has-failed – user584583

1

重申萊昂德羅說什麼,你不需要easy_install的cx_Oracle如果你已經跑了.msi安裝,你需要安裝oracle的instantclient。

正如你已經發現了,在安裝Oracle instantclient意味着你只需要簡單地把它解壓到您的系統文件夾(例如:C:\ oraclient)。

有些事情要記住:

確保您使用cx_Oracle,instantclient相同版本(或兼容版本),以及數據庫服務器本身。例如instantclient v12不支持版本10以下的數據庫服務器)。此外,請確保您使用的是全部32位或全部64位版本(包括cx_Oracle,instantclient和python本身)。

此外,您需要將環境變量ORACLE_HOME和PATH設置到解壓縮oracle instantclient的目錄(例如:C:\ oraclient)以避免您提到的ImportError錯誤(DLL加載失敗:%1爲不是有效的Win32應用程序)。 ImportError僅僅意味着它找不到所需的庫。

0

由於cx_Oracle只能使用Oracle TNS名稱工具進行連接,因此您可能還需要設置TNS_ADMIN環境變量以指示要使用的TNS名稱文件的位置。這個問題也咬我。

0

對於Windows 7 64位,您需要「Windows amd64安裝程序(Oracle 11g,Python 3.3)」。它也適用於英特爾。

我沒有InstantClient,但使用Oracle 11.2安裝(64位)中的SQL * Plus。