Feature request
Would it be possible to make psutil an optional dependency, or to provide a configuration flag allowing ipykernel to run without psutil on constrained platforms?
Context
I am running ipykernel inside a Python-for-Android / Kivy application. This setup works with ipykernel==6.9.1, but newer versions import psutil during kernel startup. On Android / python-for-android, psutil is difficult to support because it contains platform-specific native code and relies on process-inspection APIs that are not always available or useful in this environment.
The kernel itself works for the main use case:
- Jupyter messaging
- remote QtConsole control
- normal Python execution
- NumPy operations
- application-side control through the kernel namespace
The blocking point is that newer ipykernel versions require psutil even though the features using it appear to be related mainly to process/resource reporting and child-process management.
Observed psutil usage
From inspection, psutil appears to be used in areas such as:
usage_request
_process_children
_signal_children
These seem useful on desktop/server platforms, but they are not essential for all embedded/mobile use cases.
Proposed behavior
One possible approach would be:
- keep full
psutil behavior when psutil is installed;
- if
psutil is unavailable, allow the kernel to start anyway;
- degrade gracefully for features requiring process introspection;
- return limited or unavailable resource information from
usage_request;
- treat child-process enumeration as empty or unsupported.
For example, ipykernel could catch ImportError around psutil and use a small internal fallback layer.
Why this would help
This would make recent ipykernel versions usable on constrained or unusual Python targets, including:
- Android / python-for-Android
- embedded Linux systems
- restricted containers
- environments where native extension builds are not practical
Currently, users in those environments may need to pin to older ipykernel versions only to avoid the hard psutil dependency.
Current workaround
For now, I can run successfully with:
Feature request
Would it be possible to make
psutilan optional dependency, or to provide a configuration flag allowingipykernelto run withoutpsutilon constrained platforms?Context
I am running
ipykernelinside a Python-for-Android / Kivy application. This setup works withipykernel==6.9.1, but newer versions importpsutilduring kernel startup. On Android / python-for-android,psutilis difficult to support because it contains platform-specific native code and relies on process-inspection APIs that are not always available or useful in this environment.The kernel itself works for the main use case:
The blocking point is that newer
ipykernelversions requirepsutileven though the features using it appear to be related mainly to process/resource reporting and child-process management.Observed psutil usage
From inspection,
psutilappears to be used in areas such as:usage_request_process_children_signal_childrenThese seem useful on desktop/server platforms, but they are not essential for all embedded/mobile use cases.
Proposed behavior
One possible approach would be:
psutilbehavior whenpsutilis installed;psutilis unavailable, allow the kernel to start anyway;usage_request;For example,
ipykernelcould catchImportErroraroundpsutiland use a small internal fallback layer.Why this would help
This would make recent
ipykernelversions usable on constrained or unusual Python targets, including:Currently, users in those environments may need to pin to older
ipykernelversions only to avoid the hardpsutildependency.Current workaround
For now, I can run successfully with: