Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PackageNotFoundError: No package metadata was found for torch #358

Answered by chhenning
PSLHimaBindu asked this question in Q&A
Discussion options

I just cloned repository and started to run.I get following error.
PS: I just setup my VS code, installed git python etc.please suggest how to fox this error.

image image
You must be logged in to vote

Have you installed torch? I suggest you pip install -r requirements.txt

Replies: 3 comments 3 replies

Comment options

Have you installed torch? I suggest you pip install -r requirements.txt

You must be logged in to vote
1 reply
Comment options

I can confirm, the PackageNotFoundError usually occurs of the required packages are not installed, yet. I recommend running

pip install -r requirements.txt

in your terminal as suggested by @chhenning.

Alternatively, you can directly execute

!pip install -r https://raw.githubusercontent.com/rasbt/LLMs-from-scratch/main/requirements.txt

in a notebook cell.

Please let us know in case you are bumping into any issues with this.

Answer selected by rasbt
Comment options

I had this same issue, despite confirming torch was installed in my virtualenv (I could "import torch" from the python console). Turned out to be an issue only when running the notebook from PyCharm. Opening up the notebook using jupyter-lab directly worked fine.

You must be logged in to vote
1 reply
Comment options

Yeah, PackageNotFoundError: No package metadata was found for torch sounds like something is corrupt there, otherwise it would say ModuleNotFoundError: No module named 'torch'. Please make sure to use uv or pip when installing the packages, other packages managers like conda might lead to problems.

And after having installed new packages, please also don't forget to restart the kernel.

Comment options

Hi same problem here. I run in vscode and python 3.11. I'm using a conda environment.

I tried pip install -r requirements.txt twice and it says all requirements satisfied.

Finally found that by conda install pytorch will solve the problem. Also found that if you use pip install will cause problems. Make sure to use the same way to install packages

Hope this helps.

You must be logged in to vote
1 reply
Comment options

rasbt Aug 1, 2025
Maintainer

Thanks for sharing! I suspect the culprit here is that there are multiple instances of Python on that machine, and pip then links to the wrong one. E.g., you could check via which pip in the terminal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
Converted from issue

This discussion was converted from issue #357 on September 16, 2024 12:18.

AltStyle によって変換されたページ (->オリジナル) /