0

I have a problem where I am trying to use PyCharm for PyTorch. I have installed Python separately (quite a task as it tried to install it in the Microsoft/AppData folder?).

In PyCharm, I have to first manually set the Python.exe location, which is not apparent.

Then, it does not recognize any packages I installed before, I have to reinstall these from the Python Interpreter setting in PyCharm.

Okay this works.

Now however, I try to confirm PyTorch is running on my system. However, when I run command prompt, even after setting my directory to the same exact Python.exe location (this time in Program Files), I am only getting error after error trying to load PyTorch.

Example of an error in Powershell:

Installing collected packages: mpmath, typing-extensions, sympy, setuptools, pillow, numpy, networkx, MarkupSafe, fsspec, filelock, jinja2, torch, torchvision
   ━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  2/13 [sympy]  WARNING: The script isympy.exe is installed in 'C:\Users\alexa\AppData\Roaming\Python\Python314\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
   ━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━  5/13 [numpy]  WARNING: The scripts f2py.exe and numpy-config.exe are installed in 'C:\Users\alexa\AppData\Roaming\Python\Python314\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸━━━━━━ 11/13 [torch]  WARNING: The scripts torchfrtrace.exe and torchrun.exe are installed in 'C:\Users\alexa\AppData\Roaming\Python\Python314\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed MarkupSafe-2.1.5 filelock-3.19.1 fsspec-2025.9.0 jinja2-3.1.6 mpmath-1.3.0 networkx-3.5 numpy-2.3.3 pillow-11.3.0 setuptools-70.2.0 sympy-1.14.0 torch-2.9.1+cu126 torchvision-0.24.1+cu126 typing-extensions-4.15.0
PS C:\Program Files\Python314> import torch
import : The term 'import' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ import torch
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (import:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

What am I doing wrong?

Thanks.

3
  • What code are you running here? please include it. Commented Dec 7 at 17:36
  • I'm simply trying to run PyTorch in the PyCharm app, but for some reason it can't find the package, and installing it from the package manager, inside the interpreter, it gives an error. Commented Dec 8 at 19:42
  • This does not really help, you are just repeating what is already in the question. What does PyCharm have to do with powershell? Commented Dec 8 at 19:43

1 Answer 1

1

The issue is that import torch is Python code, not a PowerShell command. You can't run Python code directly in PowerShell.

Start Python interpreter first: In Powershell:

`python`

Then in the Python prompt (>>>):

import torch
print(torch.__version__)
print(torch.cuda.is_available())

But you have other issues as well.

1: You are using Python 3.14 (pre-release). PyTorch doesn't officially support Python 3.14 yet. I'd recommend uninstalling it and installing Python 3.11 or 3.12 for best compatibility.

2: You have Python installed in multiple locations:

C:\Program Files\Python314\
C:\Users\alexa\AppData\Roaming\Python\Python314\

3- The warnings tell you scripts aren't on PATH. Add these to your system PATH:

:\Program Files\Python314\
C:\Program Files\Python314\Scripts\
C:\Users\alexa\AppData\Roaming\Python\Python314\Scripts\
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.