calvin
calvin

Reputation: 15

No model named torch

Dear fellow humans and others,

i have a question about using and importing pytorch into my editor.
I installed pytorch through Conda and in my terminal editor I can use pytorch,see image
but not in Visual studio code or Pycharm! No model named torch error code in VSC
Why is that?
Very sorry for the basic question and thank you for sparing some time!
Should I use pip?

Upvotes: 0

Views: 4905

Answers (2)

Jill Cheng
Jill Cheng

Reputation: 10364

Reason: The environment where the module "torch" is stored is not the environment you currently select in VSCode.

For installing and using the module "torch" in VSCode, you could refer to the following:

  1. Check the environment. The Python environment displayed in the lower left corner of VSCode is the same as that of the terminal.

    enter image description here

  2. Install the module. (pip install torch)

  3. Run.

    enter image description here

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

    enter image description here

Reference: Environment in VSCode.

Upvotes: 0

Kaan Berke UĞURLAR
Kaan Berke UĞURLAR

Reputation: 122

First, find out your python's path by writing which python and then visit this page. You will change the project interpreter as the conda's python path. I recommend you to stick with pip but its your call, of course.

Upvotes: 1

Related Questions