You are not logged in.

#1 2024-12-28 12:30:07

tugoese
Member
Registered: 2023-10-15
Posts: 26

Python: Jupyter Notebook stopped working

I'm doing deep learning with tensorflow & keras, after full system update notebook recently stopped working, tried with python 3.11 & 3.12 also using venv but no luck. It worked fine before update

$ jupyter notebook
Traceback (most recent call last):
  File "/usr/bin/jupyter", line 5, in <module>
    from jupyter_core.command import main
ModuleNotFoundError: No module named 'jupyter_core'

python-jupyter-core already installed

Last edited by tugoese (2024-12-28 15:30:26)

Offline

#2 2024-12-28 12:40:56

mithrial
Member
Registered: 2017-03-05
Posts: 59

Re: Python: Jupyter Notebook stopped working

If you use a venv, you have to reinstall the packages, they might be using a Python version which you don't have anymore.

And from the error log, you are not using a venv.

Last edited by mithrial (2024-12-28 12:41:16)

Offline

#3 2024-12-28 12:46:17

gromit
Package Maintainer (PM)
From: Germany
Registered: 2024-02-10
Posts: 907
Website

Re: Python: Jupyter Notebook stopped working

Works fine on my machine, how did you install jupyter notebook?

$ sudo pacman -S jupyter-notebook
[...]

$ jupyter notebook
[I 2024-12-28 13:45:06.734 ServerApp] jupyterlab | extension was successfully linked.
[I 2024-12-28 13:45:06.737 ServerApp] notebook | extension was successfully linked.
[I 2024-12-28 13:45:06.963 ServerApp] notebook_shim | extension was successfully linked.
[I 2024-12-28 13:45:06.978 ServerApp] notebook_shim | extension was successfully loaded.
[I 2024-12-28 13:45:06.979 LabApp] JupyterLab extension loaded from /usr/lib/python3.13/site-packages/jupyterlab
[I 2024-12-28 13:45:06.979 LabApp] JupyterLab application directory is /usr/share/jupyter/lab
[I 2024-12-28 13:45:06.979 LabApp] Extension Manager is 'pypi'.
[I 2024-12-28 13:45:06.990 ServerApp] jupyterlab | extension was successfully loaded.
[I 2024-12-28 13:45:06.992 ServerApp] notebook | extension was successfully loaded.
[I 2024-12-28 13:45:06.993 ServerApp] Serving notebooks from local directory: /home/chris
[I 2024-12-28 13:45:06.993 ServerApp] Jupyter Server 2.15.0 is running at:
[I 2024-12-28 13:45:06.993 ServerApp] http://localhost:8888/tree?token=cef9f43962a311dd43b9856d95fdfa0300d5c78064bd8952
[I 2024-12-28 13:45:06.994 ServerApp]     http://127.0.0.1:8888/tree?token=cef9f43962a311dd43b9856d95fdfa0300d5c78064bd8952
[I 2024-12-28 13:45:06.994 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

Offline

#4 2024-12-28 13:11:46

tugoese
Member
Registered: 2023-10-15
Posts: 26

Re: Python: Jupyter Notebook stopped working

mithrial wrote:

And from the error log, you are not using a venv.

It was intentional, Both got same error

gromit wrote:

Works fine on my machine, how did you install jupyter notebook?

Through pacman, pip on venv

I downgraded Python to 3.11 because Tensorflow support it

$ sudo jupyter notebook --allow-root

This command works in venv altough I struggle to install Tensorflow /w CUDA or possible with AVX optimization with pip
Kinda odd because it should work without sudo & It doesn't open browser automatically

I wonder which one is better with or without venv

Last edited by tugoese (2024-12-28 13:31:40)

Offline

#5 2024-12-28 14:16:55

loqs
Member
Registered: 2014-03-06
Posts: 18,227

Re: Python: Jupyter Notebook stopped working

tugoese wrote:

I downgraded Python to 3.11 because Tensorflow support it

How did you downgrade python? What issues are you having with python 3.13 and tensorflow? I have not encountered any issues with that combination.

Offline

#6 2024-12-28 14:19:00

gromit
Package Maintainer (PM)
From: Germany
Registered: 2024-02-10
Posts: 907
Website

Offline

#7 2024-12-28 14:29:27

loqs
Member
Registered: 2014-03-06
Posts: 18,227

Re: Python: Jupyter Notebook stopped working

For completeness https://github.com/tensorflow/tensorflow/issues/78774
diff to current tensorflow PKGBUID that allowed me to build with python 3.13 and import the tensorflow module:

diff --git a/PKGBUILD b/PKGBUILD
index 538c24e..54b6e29 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -15,17 +15,21 @@ arch=('x86_64')
 depends=('c-ares' 'pybind11' 'openssl' 'libpng' 'curl' 'giflib' 'icu' 'libjpeg-turbo' 'intel-oneapi-openmp'
          'intel-oneapi-compiler-shared-runtime-libs')
 makedepends=('bazel' 'cuda' 'nvidia-utils' 'nccl' 'git' 'cudnn' 'openmp'
-             'python-installer' 'patchelf' 'libxcrypt-compat' 'clang' 'lld')
+             'python-installer' 'patchelf' 'libxcrypt-compat' 'clang' 'lld' gcc-fortran openblas)
 optdepends=('tensorboard: Tensorflow visualization toolkit')
 source=("$pkgname-$pkgver.tar.gz::https://github.com/tensorflow/tensorflow/archive/v${_pkgver}.tar.gz"
         tensorflow-newer-hermetic-nvidia-versions.patch
         https://github.com/tensorflow/tensorflow/commit/3f4b2fda6ffe7dfe03c1663ef37f54fc4432cc8b.patch
+        https://github.com/tensorflow/tensorflow/commit/846468dd25153e9a41f0a9da1ba1604ce819628d.patch
         tensorflow-2.16.1-python-distutils-removal.patch
+        test.patch
         https://github.com/bazelbuild/bazel/releases/download/6.5.0/bazel_nojdk-6.5.0-linux-x86_64)
 sha512sums=('177decaafcdef27afee84a17268f473141d2d0c092d5f3fe33c9cdd3ce4fd52f6b4b83bc41b4b005c8889f5e65602a57ae3eba8f63e0c527feaf83917453f4e6'
             '4c2780d69d72c8794aad252a96b21ab81d4e24cb9c6a4b89ff24f0627c7e96b58bec27e59725ef77d6673665faebcb0e958e4dd9406704899ba12fa8d313929e'
             '03e8d7188a81cc237899f4f287f129e7759d268f604252636e007e1ffe71b6a07926c219f79b5bf1f8c088345e292eff461d2375ca1a73af435cdca182e9c26c'
+            '9fb2afd75da422a930ccd10d17c3230485fb877800ea1ca246cba76bc1a70d8a196ca4361557fb4a41c12fd844fa31dd761db14ba45f400b0bb3d4d2d70d3bec'
             'e4c44d2f5314b83d8ed404e5ec14960ef8b7df0c1a2a3e826f913a02c901f9fd0326f9014a602121e0fdb2f928d1459f8b8180455491a1f937ce84e12f6a7d3e'
+            'ee8b864fe5c0a9ee012d78c3d9dd8121d08b398df97580c48559348d7da3c87c92323173de61cc1d6e2bb612a7c0eaeca493d1e615552cd266030eb23ad22076'
             'd3789f0ecd354468f2e24d98501041430ae99c173320fa9c3eb02f225c08ed298fd1ad259e4ad9bb70b6ae89d84cd87460aaa720de3486d40b30777a8fe45453')
 install=tensorflow.install
 
@@ -76,6 +80,9 @@ prepare() {
   # https://gitlab.archlinux.org/archlinux/packaging/packages/tensorflow/-/issues/7
   patch -Np1 -i ../tensorflow-2.16.1-python-distutils-removal.patch -d tensorflow-${_pkgver}
 
+  patch -Np1 -i ../846468dd25153e9a41f0a9da1ba1604ce819628d.patch -d tensorflow-${_pkgver}
+  patch -Np1 -i ../test.patch -d tensorflow-${_pkgver}
+
   # Get rid of hardcoded versions. Not like we ever cared about what upstream
   # thinks about which versions should be used anyway. ;) (FS#68772)
   sed -i -E "s/'([0-9a-z_-]+) .= [0-9].+[0-9]'/'\1'/" tensorflow-${_pkgver}/tensorflow/tools/pip_package/setup.py
@@ -84,6 +91,11 @@ prepare() {
   # Setting the variables as empty but defined does not prevent prompting by configure.py
   sed -i "/set_cuda_local_path(environ_cp, '/d" tensorflow-${_pkgver}/configure.py
 
+  cd tensorflow-${_pkgver}
+  touch requirements_lock_3_13.txt
+  bazel run //ci/official/requirements_updater:requirements.update --repo_env=HERMETIC_PYTHON_VERSION=3.13
+  cd ..
+
   cp -r tensorflow-${_pkgver} tensorflow-${_pkgver}-opt
   cp -r tensorflow-${_pkgver} tensorflow-${_pkgver}-cuda
   cp -r tensorflow-${_pkgver} tensorflow-${_pkgver}-opt-cuda

test.patch

diff --git a/WORKSPACE b/WORKSPACE
index 73cb4ee8..381d98bc 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -43,6 +43,7 @@ python_init_repositories(
         "3.10": "//:requirements_lock_3_10.txt",
         "3.11": "//:requirements_lock_3_11.txt",
         "3.12": "//:requirements_lock_3_12.txt",
+        "3.13": "//:requirements_lock_3_13.txt",
     },
 )
 
diff --git a/ci/official/requirements_updater/requirements.in b/ci/official/requirements_updater/requirements.in
index 626bcca9..d6cfa615 100644
--- a/ci/official/requirements_updater/requirements.in
+++ b/ci/official/requirements_updater/requirements.in
@@ -1,4 +1,4 @@
-numpy ~= 2.0.0
+numpy ~= 2.2.0
 wheel ~= 0.41.2
 h5py >= 3.11.0
 lit ~= 17.0.2
@@ -11,7 +11,7 @@ gast == 0.4.0
 termcolor == 2.3.0
 wrapt == 1.16.0
 tblib == 2.0.0
-ml_dtypes >= 0.4.0, < 0.5.0
+ml_dtypes >= 0.5.0
 # Install tensorboard, and keras
 # Note that here we want the latest version that matches TF major.minor version
 # Note that we must use nightly here as these are used in nightly jobs
@@ -21,13 +21,13 @@ tensorboard ~= 2.18.0
 # Test dependencies
 grpcio >= 1.24.3, < 2.0
 portpicker == 1.6.0
-scipy ~= 1.13.0
+scipy ~= 1.14.1
 requests >= 2.31.0
 packaging==23.2
 setuptools==70.0.0
 jax==0.4.7
 # The dependencies below are needed for TF wheel testing.
-tensorflow-io-gcs-filesystem==0.37.1
-libclang >= 13.0.0
-google_pasta ~= 0.2
-flatbuffers ~= 24.3.25
+#tensorflow-io-gcs-filesystem==0.37.1
+#libclang >= 13.0.0
+#google_pasta ~= 0.2
+#flatbuffers ~= 24.3.25
diff --git a/tensorflow/python/eager/pywrap_tensor.cc b/tensorflow/python/eager/pywrap_tensor.cc
index e04ad38b..7178c347 100644
--- a/tensorflow/python/eager/pywrap_tensor.cc
+++ b/tensorflow/python/eager/pywrap_tensor.cc
@@ -47,6 +47,31 @@ limitations under the License.
 #include "tensorflow/python/lib/core/pybind11_status.h"
 #include "tensorflow/python/lib/core/safe_pyobject_ptr.h"
 
+static int
+PyArg_NoKeywords(const char *funcname, PyObject *kwargs)
+{
+#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 13
+    /* Based on the one in CPython, removed from the public headers in 3.13
+     * (https://github.com/python/cpython/issues/110964)
+     */
+    if (kwargs == NULL)
+        return 1;
+    if (!PyDict_CheckExact(kwargs)) {
+        PyErr_BadInternalCall();
+        return 0;
+    }
+    if (PyDict_GET_SIZE(kwargs) == 0)
+        return 1;
+
+    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", funcname);
+    return 0;
+#else
+    return _PyArg_NoKeywords(funcname, kwargs);
+#endif
+}
+
+
+
 // forward declare
 struct EagerTensor;
 namespace tensorflow {
@@ -686,7 +711,7 @@ static int EagerTensor_settensor_shape(EagerTensor* self, PyObject* value,
 // Function `_copy_to_device`.
 static PyObject* EagerTensor_copy_to_device(EagerTensor* self, PyObject* args,
                                             PyObject* kwds) {
-  if (!_PyArg_NoKeywords("copy_to_device", kwds)) return nullptr;
+  if (!PyArg_NoKeywords("copy_to_device", kwds)) return nullptr;
 
   const char* device_name = nullptr;
   if (!PyArg_ParseTuple(args, "O&:copy_to_device", ConvertDeviceName,
@@ -873,8 +898,10 @@ static int EagerTensor_traverse(PyObject* self, visitproc visit, void* arg) {
 #if PY_VERSION_HEX < 0x030C0000  // < Python 3.12
   PyObject*& dict = *_PyObject_GetDictPtr(self);
   Py_VISIT(dict);
-#else
+#elif PY_VERSION_HEX < 0x030d0000 // < Python 3.13
   _PyObject_VisitManagedDict(self, visit, arg);
+#else
+  PyObject_VisitManagedDict(self, visit, arg);
 #endif  // PY_VERSION_HEX < 0x030C0000
   Py_VISIT(((EagerTensor*)self)->handle_data);
   Py_VISIT(((EagerTensor*)self)->tensor_shape);
@@ -896,8 +923,10 @@ extern int EagerTensor_clear(PyObject* self) {
 #if PY_VERSION_HEX < 0x030C0000  // < Python 3.12
   PyObject*& dict = *_PyObject_GetDictPtr(self);
   Py_CLEAR(dict);
-#else
+#elif PY_VERSION_HEX < 0x030d0000 // < Python 3.13
   _PyObject_ClearManagedDict(self);
+#else
+  PyObject_ClearManagedDict(self);
 #endif  // PY_VERSION_HEX < 0x030C0000
 
   Py_CLEAR(((EagerTensor*)self)->handle_data);

Last edited by loqs (2024-12-28 22:29:37)

Offline

Board footer

Powered by FluxBB