Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'scratch' #122

Open
emmanuel59 opened this issue May 1, 2023 · 1 comment
Open

ModuleNotFoundError: No module named 'scratch' #122

emmanuel59 opened this issue May 1, 2023 · 1 comment

Comments

@emmanuel59
Copy link

emmanuel59 commented May 1, 2023

I've got your book and I'm working through it.

I download the whole repo to folder c:\data-science-from-scratch on Windows.

There is the following code in chapter "statistics" from scratch.linear_algebra import sum_of_squares
In anaconda prompt I execute :

(dsfs) c:\data-science-from-scratch>python scratch\statistics.py
Traceback (most recent call last):
File "scratch\statistics.py", line 98, in
from scratch.linear_algebra import sum_of_squares
ModuleNotFoundError: No module named 'scratch'

Do you have some idea to solve the problem ?

@emmanuel59 emmanuel59 changed the title how do I install the linear_algebra library? ModuleNotFoundError: No module named 'scratch' May 2, 2023
@juanma-rm
Copy link

Hi emmanuel. I hope this answer is not too late for you and can somehow help you.

The issue arises since scratch is expected to be a module available but cannot be found by the python interpreter. scratch module corresponds to "scratch" folder provided with this repository, and linear_algebra.py is located.

Note: In my case I am not using anaconda but my own virtual environment.

I have this folder structure:
my_workspace
|_ my_venv
|_ scratch (containing all .py files, including linear_algebra.py and init.py, which are relevant here)

I run the following lines from my terminal (I am on Windows, but should work for Linux/MacOS too) in order to make the script work:
cd my_workspace
my_venv\Scripts\activate
set PYTHONPATH=./scratch # For windows
export PYTHONPATH=./scratch # For mac/linux
python3 scratch\ch8_2.py # It should work now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants