ARTICLE AD BOX
I'm a beginner in Python and GitHub, so I apologize if this is a basic question. I'm trying to make some functions available in any notebook in my project by creating a local package and installing it in editable mode with pip install -e .. However, when I try to import from the package in a notebook, I get a ModuleNotFoundError.
Project Structure
My project structure is as follows:
text
Quant-trading-journey/ ├── .gitignore ├── Phase-0/ │ └── Basic financial analysis.ipynb ├── README.md ├── data/ │ ├── spy.pkl │ └── tickers_20y.pkl ├── pyproject.toml └── src/ └── quant_utils/ ├── __init__.py (empty file) ├── data.py └── perf.pypyproject.toml Content
toml
[build-system] requires = ["setuptools>=45", "wheel"] build-backend = "setuptools.build_meta" [project] name = "quant-trading-journey" version = "0.1.0" description = "My journey to become a systematic quant trader" authors = [{name = "Sergio"}] [project.optional-dependencies] full = [ "pandas", "numpy", "yfinance", "matplotlib", "seaborn", "plotly", "vectorbt", "scikit-learn", "xgboost", "jupyter", "ipykernel" ] [tool.setuptools.packages.find] where = ["src"] include = ["quant_utils*"]Debugging Logs and Commands Used
I ran the installation in the command prompt:
cd "C:\Users\Sergio\Documents\GitHub\Quant-trading-journey" "C:\Users\Sergio\AppData\Local\Programs\Python\Python313\python.exe" -m pip install -e .Output:
Obtaining file:///C:/Users/Sergio/Documents/GitHub/Quant-trading-journey Installing build dependencies ... done Checking if build backend supports build_editable ... done Getting requirements to build editable ... done Preparing editable metadata (pyproject.toml) ... done Building wheels for collected packages: quant-trading-journey Building editable for quant-trading-journey (pyproject.toml) ... done Created wheel for quant-trading-journey: filename=quant_trading_journey-0.1.0-0.editable-py3-none-any.whl size=3023 sha256=f20897b37e1fed7f460a0e20d108900424dd3865ff59a20f9e57fc4112fcaee6 Stored in directory: C:\Users\Sergio\AppData\Local\Temp\pip-ephem-wheel-cache-7xr3encu\wheels\69\44\70\524231754e134a85e4dd82010d6ce3613f53070c94d274b02a Successfully built quant-trading-journey Installing collected packages: quant-trading-journey Successfully installed quant-trading-journey-0.1.0Then, in a Jupyter notebook in Phase-0/, I run:
from quant_utils.data import download_dataFull error stack trace:
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) Cell In[1], line 1 ----> 1 from quant_utils.data import download_data ModuleNotFoundError: No module named 'quant_utils'I launch Jupyter Notebook from Anaconda Navigator. I also tried from CMD with jupyter notebook. No virtual environment, just the base Python 3.13 installation. The kernel is the default Python 3 kernel from Anaconda .I checked with echo %PYTHONPATH% in CMD, and it returns %PYTHONPATH%. So, no PYTHONPATH is present in the environment.
Test with env PYTHONPATH: I tried the command set PYTHONPATH=src;%PYTHONPATH% & "C:\Users\Sergio\AppData\Local\Programs\Python\Python313\python.exe" src\quant_utils\perf.py. It executed without any error or output, returning to the prompt. To confirm, I added a print statement to perf.py (print("Hello from perf.py!")), and the command printed "Hello from perf.py!" successfully.
Additional Details
Python version: 3.13
The installation succeeds without errors, but the import fails when using the notebook in a subdirectory like Phase-0/.
I have tried reinstalling the package, restarting Jupyter, and ensuring no old installations are present.
The import works if I move the .py files to the same directory as the notebook, but that's not what I want for a modular project.
What am I doing wrong? How can I make the import work from any notebook in the project after the editable install?
GitHub Repo
https://github.com/ImSeekingAlpha/Quant-trading-journey
You won't see:
from quant_utils.data import download_dataOr any other import because I tried locally and it didn't work, but you can download the repo and try it yourself, you'll get a ModuleNotFound Error.
