最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - ibm_db module not found in command window - Stack Overflow

programmeradmin3浏览0评论

I am using Windows 11 and Python 3.13.2.

I have installed the ibm db2 client.

I added ibm_db_home value:

C:\Users\przyt>echo %IBM_DB_HOME%
c:\Program Files\IBM\SQLLIB

I installed ibm_db:

Name: ibm_db
Version: 3.2.6
Location: C:\Users\przyt\PycharmProjects\PythonProject\.venv\Lib\site-packages

Now using pycharm and in terminal

>>> import os
>>> os.add_dll_directory('C:\\Users\\przyt\\PycharmProjects\\PythonProject\\.venv\\Lib\\site-packages\\clidriver\\bin')
<AddedDllDirectory('C:\\Users\\przyt\\PycharmProjects\\PythonProject\\.venv\\Lib\\site-packages\\clidriver\\bin')>
>>> import ibm_db
>>> quit

No problem, all seems ok.

When doing this in regular command window,

C:\Users\przyt>py
Python 3.13.2 (tags/v3.13.2:4f8bb39, Feb  4 2025, 15:23:48) [MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.add_dll_directory('C:\\Users\\przyt\\PycharmProjects\\PythonProject\\.venv\\Lib\\site-packages\\clidriver\\bin')
<AddedDllDirectory('C:\\Users\\przyt\\PycharmProjects\\PythonProject\\.venv\\Lib\\site-packages\\clidriver\\bin')>
>>> import ibm_db
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    import ibm_db
ModuleNotFoundError: No module named 'ibm_db'
>>> quit

Is there a setting that should be done to have the same behavior in command window as in pycharm ps terminal?

Do you need to specify your project home path to specify where ibm_db is located? --- answer to reply --

python has been installed in

C:\Users\przyt\AppData\Local\Programs\Python\Python313\python.exe

when installing pycharm it requested where it was installed and created this .venv that keeps also a pyhon.exe.

if i look in settings it indicates base python = Appdata... of type venv and location is this .venv scripts folder and sys.executable is pointing to this C:\Users\przyt\PycharmProjects\PythonProject.venv\Scripts\python.exe -

so if I use the python from the venv path and import ibm_db it is ok. is this python a real copy or virtual ?

do i need the original installed python ?

best regards, Guy

I am using Windows 11 and Python 3.13.2.

I have installed the ibm db2 client.

I added ibm_db_home value:

C:\Users\przyt>echo %IBM_DB_HOME%
c:\Program Files\IBM\SQLLIB

I installed ibm_db:

Name: ibm_db
Version: 3.2.6
Location: C:\Users\przyt\PycharmProjects\PythonProject\.venv\Lib\site-packages

Now using pycharm and in terminal

>>> import os
>>> os.add_dll_directory('C:\\Users\\przyt\\PycharmProjects\\PythonProject\\.venv\\Lib\\site-packages\\clidriver\\bin')
<AddedDllDirectory('C:\\Users\\przyt\\PycharmProjects\\PythonProject\\.venv\\Lib\\site-packages\\clidriver\\bin')>
>>> import ibm_db
>>> quit

No problem, all seems ok.

When doing this in regular command window,

C:\Users\przyt>py
Python 3.13.2 (tags/v3.13.2:4f8bb39, Feb  4 2025, 15:23:48) [MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.add_dll_directory('C:\\Users\\przyt\\PycharmProjects\\PythonProject\\.venv\\Lib\\site-packages\\clidriver\\bin')
<AddedDllDirectory('C:\\Users\\przyt\\PycharmProjects\\PythonProject\\.venv\\Lib\\site-packages\\clidriver\\bin')>
>>> import ibm_db
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    import ibm_db
ModuleNotFoundError: No module named 'ibm_db'
>>> quit

Is there a setting that should be done to have the same behavior in command window as in pycharm ps terminal?

Do you need to specify your project home path to specify where ibm_db is located? --- answer to reply --

python has been installed in

C:\Users\przyt\AppData\Local\Programs\Python\Python313\python.exe

when installing pycharm it requested where it was installed and created this .venv that keeps also a pyhon.exe.

if i look in settings it indicates base python = Appdata... of type venv and location is this .venv scripts folder and sys.executable is pointing to this C:\Users\przyt\PycharmProjects\PythonProject.venv\Scripts\python.exe -

so if I use the python from the venv path and import ibm_db it is ok. is this python a real copy or virtual ?

do i need the original installed python ?

best regards, Guy

Share Improve this question edited Mar 31 at 7:53 Guy Przytula asked Mar 30 at 17:39 Guy PrzytulaGuy Przytula 291 silver badge6 bronze badges 2
  • first you could check if you use the same Python - pycharm may have own Python and it may have installed Python module ibm_db. You could check sys.executable to get /full/path/to/python and use it to run code /full/path/to/python script.py and to install modules /full/path/to/python -m pip install ... – furas Commented Mar 30 at 20:45
  • if you have it as .venv then it should have special command to activate this venv - and then it should use modules installed in .venv - maybe .venv/bin/activate – furas Commented Mar 30 at 20:47
Add a comment  | 

1 Answer 1

Reset to default 0

in the setting : I specified select existing interpreter

installed ibm_db from regular command window

now all is ok - i can use sql from both command window and pycharm

many thanks for all help, Guy

发布评论

评论列表(0)

  1. 暂无评论