Skip to content

MemoryError when importing py5 #603

@fuho

Description

@fuho

Hi,
I am struggling to get py5 running on my laptop running EndeavourOS. I am using venv, installed java using install-jdk (Installed 17 as shown in the docs), py5 installed as py5[extra]. When importig py5 I get:

❯ ipython
Python 3.13.1 (main, Dec  4 2024, 18:05:56) [GCC 14.2.1 20240910]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.32.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import py5
---------------------------------------------------------------------------
MemoryError                               Traceback (most recent call last)
Cell In[1], line 1
----> 1 import py5

File ~/PycharmProjects/play-with-ai/.venv/lib/python3.13/site-packages/py5/__init__.py:111
    108 except:
    109     started_jvm = False
--> 111 debug_info = py5_tools.get_jvm_debug_info()
    112 java_version = debug_info["jvm version"][0]
    113 if not started_jvm or java_version < 17:

File ~/PycharmProjects/play-with-ai/.venv/lib/python3.13/site-packages/py5_tools/jvm.py:169, in get_jvm_debug_info()
    167 out = dict()
    168 out["JAVA_HOME environment variable"] = os.environ.get("JAVA_HOME", "<not set>")
--> 169 out["jvm version"] = jpype.getJVMVersion()
    170 out["default jvm path"] = jpype.getDefaultJVMPath()
    171 return out

File ~/PycharmProjects/play-with-ai/.venv/lib/python3.13/site-packages/jpype/_core.py:467, in getJVMVersion()
    464     return (0, 0, 0)
    466 import re
--> 467 runtime = _jpype.JClass('java.lang.Runtime')
    468 version = runtime.class_.getPackage().getImplementationVersion()
    470 # Java 9+ has a version method

File ~/PycharmProjects/play-with-ai/.venv/lib/python3.13/site-packages/jpype/_jclass.py:99, in JClass.__new__(cls, jc, loader, initialize)
     96     return ret
     98 # Pass to class factory to create the type
---> 99 return _jpype._getClass(jc)

File ~/PycharmProjects/play-with-ai/.venv/lib/python3.13/site-packages/jpype/_jclass.py:147, in _jclassPost(res, *args)
    143 # Attach public inner classes we find
    144 #   Due to bootstrapping, we must wait until java.lang.Class is defined
    145 #   before we can access the class structures.
    146 if _jpype._java_lang_Class:
--> 147     for cls in res.class_.getDeclaredClasses():
    148         if cls.getModifiers() & 1 == 0:
    149             continue

MemoryError: 

In [2]: 

I don't have JAVA_HOME set, java is installed in ~/.jdk/jdk-17...

 ~/PycharmProjects/play-with-ai  main +3 !3 ?2 ▓▒░                                                              ░▒▓ 5m 57s  play-with-ai    22:48:56 
❯ which java
java not found

 ~/PycharmProjects/play-with-ai  main +3 !3 ?2 ▓▒░                                                                       ░▒▓ play-with-ai    22:48:59 
❯ ls -al ~/.jdk/jdk-17.0.14+7/
total 8
drwxr-xr-x 1 fuho fuho   86 Jan 22 00:41 .
drwxr-xr-x 1 fuho fuho   26 Feb 17 22:30 ..
drwxr-xr-x 1 fuho fuho  330 Jan 22 00:41 bin
drwxr-xr-x 1 fuho fuho  138 Jan 22 00:37 conf
drwxr-xr-x 1 fuho fuho  140 Jan 22 00:37 include
drwxr-xr-x 1 fuho fuho 2642 Jan 22 00:37 jmods
drwxr-xr-x 1 fuho fuho 1942 Jan 22 00:37 legal
drwxr-xr-x 1 fuho fuho 1168 Jan 22 00:41 lib
drwxr-xr-x 1 fuho fuho    8 Jan 22 00:37 man
-rw-r--r-- 1 fuho fuho 2400 Jan 22 00:41 NOTICE
-rw-r--r-- 1 fuho fuho 1626 Jan 22 00:41 release

 ~/PycharmProjects/play-with-ai  main +3 !3 ?2 ▓▒░                                                                       ░▒▓ play-with-ai    22:49:28 
❯ ~/.jdk/jdk-17.0.14+7/bin/java --version
openjdk 17.0.14 2025-01-21
OpenJDK Runtime Environment Temurin-17.0.14+7 (build 17.0.14+7)
OpenJDK 64-Bit Server VM Temurin-17.0.14+7 (build 17.0.14+7, mixed mode, sharing)

 ~/PycharmProjects/play-with-ai  main +3 !3 ?2 ▓▒░                                                                       ░▒▓ play-with-ai    22:49:48 
❯ echo $JAVA_HOME


 ~/PycharmProjects/play-with-ai  main +3 !3 ?2 ▓▒░                                                                       ░▒▓ play-with-ai    22:50:25 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions