MManke
MManke

Reputation: 133

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" }

Upvotes: 0

Views: 849

Answers (2)

Jill Cheng
Jill Cheng

Reputation: 10374

For installing and using python modules in VS Code, please refer to the following:

  1. As people mentioned, select the desired python environment in the lower left corner of VS Code.

  2. Please use the shortcut key Ctrl+Shift+` to open a new VS Code terminal, and then check whether it has entered the selected python environment.("python --version" or "pip --version")

    enter image description here

  3. Install the module.

  4. Check the installation of the module.(pip show module_name)

    enter image description here

Reference: Python environments in VS Code.

Upvotes: 0

se7en
se7en

Reputation: 880

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.

Upvotes: 2

Related Questions