Python Forum

Full Version: Visual Studio Code venv ibm_db error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Visual Studio Code venv does not allow to pip install ibm_db ( Python 3.7.9)
whereas PyCharm venv allows and then work properlly for the same Python 3.7.9 . Can not figer it out. Somebody know what to do ?
-----------------------Below the terminal info-----------------------------------------------------
Detected 64-bit Python
Db2 installation detected ...
Traceback (most recent call last):
File "c:\roboczy\python37venv\.venv\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 351, in <module>
main()
File "c:\roboczy\python37venv\.venv\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 333, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "c:\roboczy\python37venv\.venv\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "C:\Users\zdzis\AppData\Local\Temp\pip-build-env-y_q_1jmh\overlay\Lib\site-packages\setuptools\build_meta.py", line 338, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "C:\Users\zdzis\AppData\Local\Temp\pip-build-env-y_q_1jmh\overlay\Lib\site-packages\setuptools\build_meta.py", line 320, in _get_build_requires
self.run_setup()
File "C:\Users\zdzis\AppData\Local\Temp\pip-build-env-y_q_1jmh\overlay\Lib\site-packages\setuptools\build_meta.py", line 335, in run_setup
exec(code, locals())
File "<string>", line 129, in <module>
File "<string>", line 91, in _getinstalledDb2Path
IndexError: list index out of range
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
VSCode isn't involved in installing packages. I would open up a shell (not in vscode), activate the venv, and do pip install from the shell. Does it work?

Is the same OS in both cases? Is it the same machine? I've had wheels fail because I didn't have all the required tools installed and all the correct paths defined.
It is the same machine, the same Windows
You can open shell within VSCode, but that won't help in this instance.

The problem here, is that the package does not use pip.
It is a driver, and as must be downloaded by clicking on the download link.
Then extracted and installed. Unless you can find a wheel for the package.

PyPi Wrote:https://pypi.org/project/ibm-db/#files->Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
...

see GitHub page here: https://github.com/ibmdb/python-ibmdb
Does not work. Again the same info on the screen

(.venv) C:\Roboczy\Python37Venv>py -m pip install C:/users/zdzis/Downloads/ibm_db-3.1.3.tar.gz
Examaple from start make an enviroment and give it name(this make easier to an avoid conflicts).
G:\div_code\answer
λ python -m venv ibm_env

G:\div_code\answer
λ cd ibm_env\

G:\div_code\answer\ibm_env
λ G:\div_code\answer\ibm_env\Scripts\activate

(ibm_env) G:\div_code\answer\ibm_env
λ pip install ibm-db
Collecting ibm-db
  Downloading ibm_db-3.1.3.tar.gz (1.4 MB)
     ---------------------------------------- 1.4/1.4 MB 4.4 MB/s eta 0:00:00
  Installing build dependencies ... done
  ....
Successfully built ibm-db
Installing collected packages: ibm-db
Successfully installed ibm-db-3.1.3
Make file in this folder ibm_test.py
import ibm_db_dbi

print(ibm_db_dbi.Connection)
print(ibm_db_dbi.__version__)
Start Vs Code from this folder(keep envioment active) using code . the it will find virtual enviroment in the list.
[Image: 7ojMLT.png]
What do you have in environment var paths ? I feel that is the key to that puzzle :)
(Nov-12-2022, 07:36 PM)mesi1000 Wrote: [ -> ]What do you have in environment var paths ? I feel that is the key to that puzzle :)
No,virtual environment don't use OS environment path at all.
The virtual environment environment variable is only available if the virtual environment is activated.
The point of me doing the the first post was so you could do the same from command line.
I use cmder,but commands is just the same in cmd or PowerShell.

I have Python 3.10 set as OS environment variable.
G:\div_code\answer
λ pip -V
pip 22.3 from C:\python310\lib\site-packages\pip (python 3.10)

G:\div_code\answer
λ where python
C:\python310\python.exe

G:\div_code\answer
λ pip -V
pip 22.3 from C:\python310\lib\site-packages\pip (python 3.10)
If i activate ibm_env it will use the Path in this folde,and environment path is not used.
(ibm_env) G:\div_code\answer\ibm_env
λ python -V
Python 3.10.5

(ibm_env) G:\div_code\answer\ibm_env
λ python -c "import sys; print(sys.executable)"
G:\div_code\answer\ibm_env\Scripts\python.exe

(ibm_env) G:\div_code\answer\ibm_env
λ pip -V
pip 22.0.4 from G:\div_code\answer\ibm_env\lib\site-packages\pip (python 3.10)