[Python] Streamlit - ModuleNotFoundError: No module named 'torch' (Mac OS)

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

  1. Stack

    Stack Membro Participativo

    I am trying to have execute Cartoon-StyleGan2 on my Mac OS, but it shows the error when I start the code. I have tried few ways like downgrading my python version, executing in python environment, as well as checking my env have torch installed properly, but still unable to run the code properly. Is it because the torch version is incompatible to the original project which was 1.8.0?

    [​IMG]

    https://github.com/happy-jihye/Streamlit-Tutorial

    Tried Solutions:

    • Tried to downgrade python to 3.8.0 because the project seems to be tested in PyTorch 1.8.0, CUDA 11.1. can't downgrade anymore because python 3.8.0 is deprecated.
    • Reinstalled torch through official site under OS with

    pip3 install torch torchvision
    ​
    • I use pip list and PyTorch already did show in my list, it is shown as torch 2.6.0
    • use pip install torch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 on version 3.9.3

    ERROR: Could not find a version that satisfies the requirement torch==1.8.0 (from versions: 1.9.0, 1.10.0, 1.10.1, 1.10.2, 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.4.0, 2.4.1, 2.5.0, 2.5.1, 2.6.0)
    ​
    • When use python to execute it works

    import torch
    print(torch.__version__) -- Shows 2.6.0​

    Continue reading...

Compartilhe esta Página