[Python] Python code only works in powershell when I import torch

Discussão em 'Python' iniciado por Stack, Abril 13, 2025.

  1. Stack

    Stack Membro Participativo

    I am running a python code where I am making a function that uses np.polyfit (I know it's deprecated but issue remains with polynomial.fit()). The fit is on a small amount of data (10 points).

    In windows, when I run it from powershell, the code fails at the polyfit without giving an error. A try except around it does not help. In debugging it I noticed two things:

    • If I run the code from bash (same computer just have bash installed in my terminal) it works. The bash uses an older version of python (3.8 vs 3.12 for powershell).
    • If I import torch it works fine from powershell. I don't need torch for this particular code however.

    As far as I can tell torch is not changing the numpy version in use. When I print out numpy__config__.show() I get the same results with and without torch so the environment seems to remain the same.

    What is leading to this behavior?

    Continue reading...

Compartilhe esta Página