0

Trying to import "libgen_api" module but get "Module not found" error.

Pip install libgen-api shows "requirement already satisfied" and the module exists in the python folder as well.

The documentation of the module says that it has to be called with libgen_api.

Other modules work fine. I am using VScode but the problem persists in the python terminal as well. I apologize if this question is redundant but so far I have not been able to find a solution anywhere.

  • how are you importing the library? is it like this : `from libgen_api import LibgenSearch` – XXDIL Apr 01 '21 at 10:36
  • your syntax is correct so must be an enviroment issue. have you checked where libgen_api is installed, from your terminal have you checked sys.path to see if it has the path where libgen ins installed? – Chris Doyle Apr 01 '21 at 10:41
  • @XXDIL yeah, I even copy-pasted the example code but the error persists – Dave Closinger Apr 01 '21 at 10:42
  • do your system have multiple python versions like Python 2.x and Python 3.x? – Yashasvi Bhatt Apr 01 '21 at 10:44
  • @ChrisDoyle the module is installed in /python39 but sys.path shows /python38-32. How should I fix this? – Dave Closinger Apr 01 '21 at 10:51
  • seems like you have more then one python version and installed the module in version B but running your terminal in version A. my first recomendation would be to used virtual enviroments like `venv` or `pipenv` as these make managing modules much easier for your projects – Chris Doyle Apr 01 '21 at 10:52
  • @DaveClosinger, does this answer your question about python path and vscode? https://stackoverflow.com/questions/48135624/how-can-i-change-python-version-in-visual-studio-code – collinsuz Apr 01 '21 at 10:59
  • @collinsuz yep, that did it. Chose python39, which was the version under which the module was installed. Thanks a lot for the help, had no idea how to fix it :) – Dave Closinger Apr 01 '21 at 11:21

1 Answers1

2

The problem was that VScode sys.path showed python38-32 but the module was installed in python39. To fix the issue go to View -> Command pallete -> select interpreter and make sure to use the version under which pip installed the module.

This answered my question. How can I change python version in Visual Studio Code?