Torch is not being found

moemoussa: <p>hello,<br>
can someone help me im trying to run a training script for a module and the first error i got in the command prompt is this :<br>
ModuleNotFoundError: No module named ‘torch’</p>
<p>but i already have it installed here are the commands i ran and outputs i got :<br>
C:\Users\moham\Desktop\mohamad\uni\thesis&gt;pip install torch<br>
Requirement already satisfied: torch in c:\users\moham\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (2.2.2)<br>
Requirement already satisfied: filelock in c:\users\moham\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from torch) (3.13.1)<br>
Requirement already satisfied: typing-extensions&gt;=4.8.0 in c:\users\moham\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from torch) (4.9.0)<br>
Requirement already satisfied: sympy in c:\users\moham\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from torch) (1.12)<br>
Requirement already satisfied: networkx in c:\users\moham\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from torch) (3.2.1)<br>
Requirement already satisfied: jinja2 in c:\users\moham\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from torch) (3.1.3)<br>
Requirement already satisfied: fsspec in c:\users\moham\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from torch) (2024.2.0)<br>
Requirement already satisfied: MarkupSafe&gt;=2.0 in c:\users\moham\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from jinja2-&gt;torch) (2.1.5)<br>
Requirement already satisfied: mpmath&gt;=0.19 in c:\users\moham\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from sympy-&gt;torch) (1.3.0)</p>
<p>C:\Users\moham\Desktop\mohamad\uni\thesis&gt;where python<br>
C:\Users\moham.pyenv\pyenv-win\shims\python<br>
C:\Users\moham.pyenv\pyenv-win\shims\python.bat<br>
C:\Users\moham\AppData\Local\Microsoft\WindowsApps\python.exe</p>
<p>C:\Users\moham\Desktop\mohamad\uni\thesis&gt;python -c “import site; print(site.getsitepackages())”<br>
[‘C:\Users\moham\.pyenv\\pyenv-win\versions\3.13.0a6’, ‘C:\Users\moham\.pyenv\pyenv-win\versions\3.13.0a6\Lib\site-packages’]</p>

PerfectionistAF: <p>Did you try uninstalling then installing it again?<br>
Also try updating pip and checking your environment</p>

moemoussa: <p>multiple times but still not working , chatgbt gave me this reply :<br>
Based on the output you provided, it seems that you are using a Python interpreter managed by <code>pyenv</code>, and the version is <code>3.13.0a6</code>. However, PyTorch is not installed in this Python environment, as indicated by the absence of its path in the <code>site-packages</code> directories.</p>
<p>To resolve the issue and ensure that PyTorch is installed and accessible from your Python environment managed by <code>pyenv</code>, you can follow these steps:</p>
<ol>
<li>
<p><strong>Activate <code>pyenv</code> Environment</strong>:<br>
If you have multiple Python versions installed via <code>pyenv</code>, make sure to activate the environment where you want to install PyTorch. You can do this using the <code>pyenv global</code>, <code>pyenv local</code>, or <code>pyenv shell</code> commands.</p>
</li>
<li>
<p><strong>Install PyTorch</strong>:<br>
Once you have activated the desired <code>pyenv</code> environment, you can install PyTorch using pip. Run the following command to install PyTorch:</p>
<pre><code class="lang-auto">pip install torch torchvision torchaudio
</code></pre>
</li>
<li>
<p><strong>Verify Installation</strong>:<br>
After installation, you can verify that PyTorch is installed correctly by importing it in a Python interpreter session. Run the following command:</p>
<pre><code class="lang-auto">python -c "import torch; print(torch.__version__)"
</code></pre>
</li>
<li>
<p><strong>Check Python Path</strong>:<br>
Double-check that the Python interpreter being used in your command prompt or terminal corresponds to the <code>pyenv</code> environment where PyTorch is installed. You can use the <code>which python</code> or <code>where python</code> command to check the Python interpreter location.</p>
</li>
</ol>
<p>By following these steps, you should be able to install PyTorch in your <code>pyenv</code> environment and ensure that it is accessible from your Python interpreter. If you encounter any issues during the installation process, please let me know, and I’ll be happy to assist you further.</p>
<p>but that didnt work either</p>

PerfectionistAF: <p>Please check or reset your python environment<br>
I believe you might be using the Windows built-in environment which is quite risky. It’s better to download anaconda and python separately and away from windows/python.bat then add python, anaconda/scripts, python/scripts to your environment variables.</p>

moemoussa: <p>working in anaconda environment worked thank you , but why does it glitch like that when i use the windows built in environment?</p>