Search code examples
pythonvisual-studio-codeimportpycharmvscode-code-runner

Can't import Python modules after transferring to VSCode from PyCharm


My basic issue is that I get an error whenever I try to import a Python module in VSCode, which doesn't happen when using PyCharm.

From what I've read so far the problem seems to be with the python path, or the interpreter. My issue is, that I don't really understand what the issue is, meaning I quickly feel lost when trying to apply some of the other solutions I have found, because I don't know what to look for.

Can someone clarify what is going wrong and how to fix it?

Edit: I probably forgot to add a crucial detail. I was facing this issue when running my python files using the code runner. This is what I needed to add to my settings.json in order to get everything working completely: "code-runner.executorMap": { "python": "$enterPythonPathhere" }


Solution

  • In VS Code press Ctrl+Shift+P Type select interpreter in the search box

    Python: Select Interpreter
    

    This will show a couple of environment paths. Click on the environment you were using in pycharm.

    If your pycharm environment does show on the list you should enter the environment path instead. That should work.