pdm-project / pdm

A modern Python package and dependency manager supporting the latest PEP standards
https://pdm-project.org
MIT License
7.89k stars 392 forks source link

Running Jupyter Notebook with PDP does not load other dependencies #3222

Open ksinkar opened 2 hours ago

ksinkar commented 2 hours ago

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

PDM is installed with ASDF. OS is GNU/Linux Distro is Fedora 40 Python is system python which is installed along with Fedora PEP 582 NOT enabled.

pdm add jupyter 
pdm add astropy
pdm run jupyter notebook

Actual behavior

In jupyter notebook running

import astropy

gives the following error

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 import astropy

ModuleNotFoundError: No module named 'astropy'

Expected behavior

Importing astropy in jupyter notebook should not give an error.

When I simply run

pdm run

I get a python REPL where when I do

import astropy

there is no problem

Environment Information

pdm info

PDM version:
  2.19.2
Python Interpreter:
  $HOME/Documents/$PROJECTDIR/.venv/bin/python (3.12)
Project Root:
  $HOME/Documents/$PROJECTDIR/
Local Packages:

pdm info --env

{
  "implementation_name": "cpython",
  "implementation_version": "3.12.6",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.11.3-200.fc40.x86_64",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT_DYNAMIC Thu Oct 10 22:31:19 UTC 2024",
  "python_full_version": "3.12.6",
  "platform_python_implementation": "CPython",
  "python_version": "3.12",
  "sys_platform": "linux"
}
frostming commented 2 hours ago

make sure the core is selected correctly and why not check the sys.path / sys.executable in the notebook