我想使用Python来处理OracleDb,因此我安装了pip install cx_Oracle
。在我处理它的整个过程中,一切都进行得很顺利,但是当我再次想打开cx_Oracle时,它显示了以下错误:
‘导入’不被识别为内部或外部命令、可操作的程序或批处理文件。
然后我继续卸载它:
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.
那么,为什么即使在成功安装之后,也会出现错误:
‘导入’不被识别为内部或外部命令、可操作的程序或批处理文件。
我不明白,谁能给我解释一下,至少每次发生的时候,我都会有理由的。非常感谢!
发布于 2021-12-22 10:22:19
您在Windows命令行中运行import cx_Oracle
,而不是在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中可能有不同的名称,如python3
或py
。如果没有这些操作,则需要检查Python是否“添加到路径”(google it)。
https://stackoverflow.com/questions/70447446
复制相似问题