iT邦幫忙

0

請問在Visual Studio中如何正確 import cx_Oracle

  • 分享至 

  • xImage

請問各位大大

import cx_Oracle 時出現下列錯誤訊息,請問該如何處理?

Python 3.9 (64-bit) 互動視窗 [PTVS 16.11.21196.2-16.0]
鍵入 $help 可取得命令清單。

import cx_Oracle
Error using selected REPL back-end:
Traceback (most recent call last):
File "c:\program files (x86)\microsoft visual studio\2019\professional\common7\ide\extensions\microsoft\python\core\ptvsd_repl_launcher.py", line 81, in _run_repl
backend_type = getattr(import(backend_mod_name, fromlist=['*']), backend_name)
File "c:\program files (x86)\microsoft visual studio\2019\professional\common7\ide\extensions\microsoft\python\core\ptvsd\repl\ipython.py", line 49, in
from .ipython_client import IPythonBackend, IPythonBackendWithoutPyLab
File "c:\program files (x86)\microsoft visual studio\2019\professional\common7\ide\extensions\microsoft\python\core\ptvsd\repl\ipython_client.py", line 31, in
from base64 import decodestring
ImportError: cannot import name 'decodestring' from 'base64' (C:\Users\joylin\AppData\Local\Programs\Python\Python39\lib\base64.py)

Using standard backend instead
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'cx_Oracle'

看更多先前的討論...收起先前的討論...
kennex_x iT邦新手 4 級 ‧ 2023-08-23 15:15:49 檢舉
ModuleNotFoundError: No module named 'cx_Oracle'
錯誤訊息是顯示你沒有安裝這個套件,官方安裝語法如下:
python -m pip install cx_Oracle
kennex_x iT邦新手 4 級 ‧ 2023-08-23 15:16:10 檢舉
https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html
joy036 iT邦研究生 3 級 ‧ 2023-08-23 15:23:25 檢舉
有安裝
PS C:\Users\joylin\AppData\Local\Programs\Python\Python39> python -m pip install cx_Oracle
Requirement already satisfied: cx_Oracle in c:\users\joylin\appdata\roaming\python\python39\site-packages (8.3.0)
PS C:\Users\joylin\AppData\Local\Programs\Python\Python39>
kennex_x iT邦新手 4 級 ‧ 2023-08-23 15:25:47 檢舉
確認一下你的VSCode的Interpreter調用的Python是不是跟你安裝cx_Oracle所使用的Python為同一個Python
joy036 iT邦研究生 3 級 ‧ 2023-08-23 16:42:45 檢舉
好像不同,請問該如何調整?
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
kennex_x
iT邦新手 4 級 ‧ 2023-08-25 11:24:54

Dears,

2個方向除錯

  1. ModuleNotFoundError: No module named 'cx_Oracle'
  2. Visual Studio Code Interpreter

For ModuleNotFoundError
python -m pip install cx_Oracle

For Visual Studio Code Interpreter
Step 1.
https://ithelp.ithome.com.tw/upload/images/20230825/20156797koxAWKmSZz.png
Step 2.
https://ithelp.ithome.com.tw/upload/images/20230825/20156797CmLf9NaydZ.png
Step 3.
https://ithelp.ithome.com.tw/upload/images/20230825/20156797BN0oN6hpoJ.png

根據你自己的狀況進行調整喔。

我要發表回答

立即登入回答