vscode-code-runner icon indicating copy to clipboard operation
vscode-code-runner copied to clipboard

[Bug] CodeRunner could not find scipy module lib, but works in terminal

Open SpikyClip opened this issue 5 years ago • 1 comments

  • VS Code Version: 1.59.1
  • OS Version: Windows_NT x64 10.0.19043
  • Code Runner Version: v0.11.5

Describe the bug When trying to execute import sklearn.tree import DecisionTreeClassifier in python using coderunner, it cannot find a module used in scikit-learn. However, when executing it in terminal, it executes successfully. The file libbanded5x.IZGAKAQ4ANQMGVOZXIKCPSCJQLZTG7O5.gfortran-win_amd64.dll does exist.

To Reproduce Steps to reproduce the behavior:

  1. conda install scikit.learn=0.24.2
  2. Create a test.py script with import sklearn.tree
  3. Run test.py with coderunner ctrl + alt + n

Actual behavior

Running with CodeRunner:

[Running] C:\Users\Vikesh\miniconda3\envs\dtl\python.exe -u "d:\Dropbox\Education\2020_2022_SMBB\year_2\CSE5DMI_data_mining\CSE5DMI_assignment_1\20596064_part_1.py"
Traceback (most recent call last):
  File "d:\Dropbox\Education\2020_2022_SMBB\year_2\CSE5DMI_data_mining\CSE5DMI_assignment_1\20596064_part_1.py", line 2, in <module>
    from sklearn.tree import DecisionTreeClassifier
  File "C:\Users\Vikesh\miniconda3\envs\dtl\lib\site-packages\sklearn\__init__.py", line 82, in <module>
    from .base import clone
  File "C:\Users\Vikesh\miniconda3\envs\dtl\lib\site-packages\sklearn\base.py", line 17, in <module>
    from .utils import _IS_32BIT
  File "C:\Users\Vikesh\miniconda3\envs\dtl\lib\site-packages\sklearn\utils\__init__.py", line 20, in <module>
    from scipy.sparse import issparse
  File "C:\Users\Vikesh\miniconda3\envs\dtl\lib\site-packages\scipy\__init__.py", line 136, in <module>
    from . import _distributor_init
  File "C:\Users\Vikesh\miniconda3\envs\dtl\lib\site-packages\scipy\_distributor_init.py", line 59, in <module>
    WinDLL(os.path.abspath(filename))
  File "C:\Users\Vikesh\miniconda3\envs\dtl\lib\ctypes\__init__.py", line 382, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\Vikesh\miniconda3\envs\dtl\lib\site-packages\scipy\.libs\libbanded5x.IZGAKAQ4ANQMGVOZXIKCPSCJQLZTG7O5.gfortran-win_amd64.dll' (or one of its dependencies). Try using the full path with constructor syntax.

[Done] exited with code=1 in 0.666 seconds

Running with terminal:

(dtl) D:\Dropbox\Education\2020_2022_SMBB\year_2\CSE5DMI_data_mining\CSE5DMI_assignment_1>C:/Users/Vikesh/miniconda3/envs/dtl/python.exe d:/Dropbox/Education/2020_2022_SMBB/year_2/CSE5DMI_data_mining/CSE5DMI_assignment_1/20596064_part_1.py

(dtl) D:\Dropbox\Education\2020_2022_SMBB\year_2\CSE5DMI_data_mining\CSE5DMI_assignment_1>

Expected behavior CodeRunner should give the same output as running in Terminal i.e. the script runs successfully.

Additional Info

Here is the full package list in my conda environment dtl:

# packages in environment at C:\Users\Vikesh\miniconda3\envs\dtl:
#
# Name                    Version                   Build  Channel
anyio                     3.3.0            py39hcbf5309_0    conda-forge    
appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge    
argon2-cffi               20.1.0           py39hb82d6ee_2    conda-forge    
async_generator           1.10                       py_0    conda-forge    
attrs                     21.2.0             pyhd8ed1ab_0    conda-forge    
babel                     2.9.1              pyh44b312d_0    conda-forge    
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge    
backports                 1.0                        py_2    conda-forge    
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
black                     21.7b0             pyhd8ed1ab_0    conda-forge    
bleach                    4.1.0              pyhd8ed1ab_0    conda-forge    
brotlipy                  0.7.0           py39hb82d6ee_1001    conda-forge  
ca-certificates           2021.5.30            h5b45459_0    conda-forge    
certifi                   2021.5.30        py39hcbf5309_0    conda-forge    
cffi                      1.14.6           py39h0878f49_0    conda-forge    
chardet                   4.0.0            py39hcbf5309_1    conda-forge    
charset-normalizer        2.0.0              pyhd8ed1ab_0    conda-forge    
click                     8.0.1            py39hcbf5309_0    conda-forge    
colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
conda-package-handling    1.7.3            py39hb3671d1_0    conda-forge
console_shortcut          0.1.1                         4
cryptography              3.4.7            py39hd8d06c1_0    conda-forge
dataclasses               0.8                pyhc8e2a94_3    conda-forge
debugpy                   1.4.1            py39h415ef7b_0    conda-forge
decorator                 5.0.9              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
entrypoints               0.3             pyhd8ed1ab_1003    conda-forge
idna                      3.1                pyhd3deb0d_0    conda-forge
importlib-metadata        4.7.1            py39hcbf5309_1    conda-forge
intel-openmp              2021.3.0          h57928b3_3372    conda-forge
ipykernel                 6.2.0            py39h832f523_0    conda-forge
ipython                   7.26.0           py39h832f523_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
jedi                      0.18.0           py39hcbf5309_2    conda-forge
jinja2                    3.0.1              pyhd8ed1ab_0    conda-forge
joblib                    1.0.1              pyhd8ed1ab_0    conda-forge
json5                     0.9.5              pyh9f0ad1d_0    conda-forge
jsonschema                3.2.0              pyhd8ed1ab_3    conda-forge
jupyter_client            7.0.1              pyhd8ed1ab_0    conda-forge
jupyter_core              4.7.1            py39hcbf5309_0    conda-forge
jupyter_server            1.10.2             pyhd8ed1ab_0    conda-forge
jupyterlab                3.1.9              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jupyterlab_server         2.7.2              pyhd8ed1ab_0    conda-forge
libblas                   3.9.0              11_win64_mkl    conda-forge
libcblas                  3.9.0              11_win64_mkl    conda-forge
liblapack                 3.9.0              11_win64_mkl    conda-forge
libsodium                 1.0.18               h8d14728_1    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6    conda-forge
m2w64-gcc-libs            5.3.0                         7    conda-forge
m2w64-gcc-libs-core       5.3.0                         7    conda-forge
m2w64-gmp                 6.1.0                         2    conda-forge
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    conda-forge
markupsafe                2.0.1            py39hb82d6ee_0    conda-forge
matplotlib-inline         0.1.2              pyhd8ed1ab_2    conda-forge
menuinst                  1.4.17           py39hcbf5309_1    conda-forge
mistune                   0.8.4           py39hb82d6ee_1004    conda-forge
mkl                       2021.3.0           hb70f87d_564    conda-forge
msys2-conda-epoch         20160418                      1    conda-forge
mypy_extensions           0.4.3            py39hcbf5309_3    conda-forge
nbclassic                 0.3.1              pyhd8ed1ab_1    conda-forge
nbclient                  0.5.4              pyhd8ed1ab_0    conda-forge
nbconvert                 6.1.0            py39hcbf5309_0    conda-forge
nbformat                  5.1.3              pyhd8ed1ab_0    conda-forge
nest-asyncio              1.5.1              pyhd8ed1ab_0    conda-forge
notebook                  6.4.3              pyha770c72_0    conda-forge
numpy                     1.21.2           py39h6635163_0    conda-forge
openssl                   1.1.1k               h8ffe710_1    conda-forge
packaging                 21.0               pyhd8ed1ab_0    conda-forge
pandas                    1.3.2            py39h2e25243_0    conda-forge
pandoc                    2.14.2               h8ffe710_0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
parso                     0.8.2              pyhd8ed1ab_0    conda-forge
pathspec                  0.9.0              pyhd8ed1ab_0    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pip                       21.2.4             pyhd8ed1ab_0    conda-forge
powershell_shortcut       0.0.1                         3
prometheus_client         0.11.0             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.20             pyha770c72_0    conda-forge
pycosat                   0.6.3           py39hb82d6ee_1006    conda-forge
pycparser                 2.20               pyh9f0ad1d_2    conda-forge
pygments                  2.10.0             pyhd8ed1ab_0    conda-forge
pyopenssl                 20.0.1             pyhd8ed1ab_0    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyrsistent                0.17.3           py39hb82d6ee_2    conda-forge
pysocks                   1.7.1            py39hcbf5309_3    conda-forge
python                    3.9.6           h7840368_1_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python_abi                3.9                      2_cp39    conda-forge
pytz                      2021.1             pyhd8ed1ab_0    conda-forge
pywin32                   301              py39hb82d6ee_0    conda-forge
pywinpty                  1.1.3            py39h99910a6_0    conda-forge
pyzmq                     22.2.1           py39he46f08e_0    conda-forge
regex                     2021.8.28        py39hb82d6ee_0    conda-forge
requests                  2.26.0             pyhd8ed1ab_0    conda-forge
requests-unixsocket       0.2.0                      py_0    conda-forge
ruamel_yaml               0.15.80         py39hb82d6ee_1004    conda-forge
scikit-learn              0.24.2           py39he931e04_1    conda-forge
scipy                     1.7.1            py39hc0c34ad_0    conda-forge
send2trash                1.8.0              pyhd8ed1ab_0    conda-forge
setuptools                57.4.0           py39hcbf5309_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sniffio                   1.2.0            py39hcbf5309_1    conda-forge
sqlite                    3.36.0               h8ffe710_0    conda-forge
tbb                       2021.3.0             h2d74725_0    conda-forge

SpikyClip avatar Aug 28 '21 02:08 SpikyClip

I've been having this issue as well and I believe I've pinpointed it, but I'm yet to find a solution.

What seems to be happening is that despite selecting the correct Python interpreter in VSCode, Code-Runner is using the base environment instead of the selected one. I verified this by running the following code.

import os
os.system("conda env list")

The output confirmed that the env being used is "base", not the one selected. Changing the executorMap and the pythonPath in the settings.json file did not fix this at all.

charya-s avatar Nov 16 '21 10:11 charya-s