Reputation: 2873
I am running Windows 10. Today I installed lightgbm
through anaconda using
conda install -c conda-forge lightgbm
However, when I tried to import lightgbm (running Jupyter Notebook), I got the following error trace:
---------------------------------------------------------------------------
CalledProcessError Traceback (most recent call last)
<ipython-input-2-5dacb4a27011> in <module>
----> 1 import lightgbm as lgb
D:\RI\0Teaching Materials\QTDM-II\P30 LGBM\lightgbm.py in <module>
10
11 from subprocess import check_output
---> 12 print(check_output(["ls", "../input"]).decode("utf8"))
13
14 # Any results you write to the current directory are saved as output.
~\Anaconda3\lib\subprocess.py in check_output(timeout, *popenargs, **kwargs)
334
335 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
--> 336 **kwargs).stdout
337
338
~\Anaconda3\lib\subprocess.py in run(input, timeout, check, *popenargs, **kwargs)
416 if check and retcode:
417 raise CalledProcessError(retcode, process.args,
--> 418 output=stdout, stderr=stderr)
419 return CompletedProcess(process.args, retcode, stdout, stderr)
420
CalledProcessError:Command '['ls', '../input']' returned non-zero exit status 2.
What is preventing me from importing lightgbm
?
Update:- Thinking that this is a Windows issue, I installed Anaconda on Ubuntu (Oracle VB) and tried import. Unfortunately, same error occurred in this environment too. What could be behind this?
Upvotes: 0
Views: 579
Reputation: 2382
It looks like you have D:\RI\0Teaching Materials\QTDM-II\P30 LGBM\ in your PYTHONPATH, you can check it in the notebook by:
import sys
print(sys.path)
or on commandline
echo %PYTHONPATH%
The directory will be in the python path if you start the notebook in that directory. Because you have that directory in the python path, when you try to import module lightgbm, python is finding lightgbm.py file and then imports it, and in that file you have code that is shelling out to 'ls ../input' and you do not have 'ls' on Windows, hence the error. Second possibility is that the ls command can not see ../input because file does not exist. this does not mater, issue is still that import statement is finding lightgbm.py file before it finds the lightgbm module that you have installed with conda and actually want to import. (Hacky fix would be to rename lightgbm.py to something else)
Fix your PYTHONPATH, you can unset it following: https://superuser.com/questions/949560/how-do-i-set-system-environment-variables-in-windows-10
Upvotes: 1