我想使用 Python 在 OracleDb 上作業,因此我安裝了pip install cx_Oracle. 在我處理它的整個程序中,一切都很好,但過了一段時間,當我再次想打開 cx_Oracle 時,它??顯示了這個錯誤:
'import' 不是內部或外部命令,也不是可運行的程式或批處理檔案。
然后我繼續卸載它:
C:\Users\PRATIKBAWANE>pip uninstall cx_Oracle
Found existing installation: cx-Oracle 8.3.0
Uninstalling cx-Oracle-8.3.0:
Would remove:
c:\users\pratikbawane\appdata\local\programs\python\python310\cx_oracle-doc\license.txt
c:\users\pratikbawane\appdata\local\programs\python\python310\cx_oracle-doc\readme.txt
c:\users\pratikbawane\appdata\local\programs\python\python310\lib\site-packages\cx_oracle-8.3.0.dist-info\*
c:\users\pratikbawane\appdata\local\programs\python\python310\lib\site-packages\cx_oracle.cp310-win_amd64.pyd
Proceed (Y/n)? y
Successfully uninstalled cx-Oracle-8.3.0
并再次嘗試安裝它:
C:\Users\PRATIKBAWANE>pip install cx_Oracle
Collecting cx_Oracle
Using cached cx_Oracle-8.3.0-cp310-cp310-win_amd64.whl (213 kB)
Installing collected packages: cx-Oracle
Successfully installed cx-Oracle-8.3.0
WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
You should consider upgrading via the 'C:\Users\PRATIKBAWANE\AppData\Local\Programs\Python\Python310\python.exe -m pip install --upgrade pip' command.
C:\Users\PRATIKBAWANE>import cx_Oracle
'import' is not recognized as an internal or external command,
operable program or batch file.
那么為什么即使在成功安裝后它仍然顯示錯誤:
'import' 不是內部或外部命令,也不是可運行的程式或批處理檔案。
我不明白有人可以向我解釋,這樣至少無論何時發生,我都可能有原因。太感謝了!
uj5u.com熱心網友回復:
您import cx_Oracle在 Windows 命令列中運行,而不是在 Python 解釋器中運行。您需要先啟動 Python,如下所示:
C:\Users\PRATIKBAWANE>python
Python 3.9.9 (main, Dec 13 2021, 17:45:33)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>>
python在 Windows cmd 中可能有不同的名稱,例如python3或py。如果這些都不起作用,您需要檢查 Python 是否“添加到 PATH”(谷歌它)
uj5u.com熱心網友回復:
為什么要在終端中撰寫它?匯入不是終端命令,而是 python 之一。您應該首先在終端中運行 python,打開它的解釋器并撰寫 python 代碼。或者只是在編輯器中撰寫 python 代碼并在終端中編譯它。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/389862.html
上一篇:oracle中的遞回函式?
