Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code works, but unresolved reference errors in the editor and many errors generated on running #340

Closed
TimB1023 opened this issue Apr 13, 2022 · 5 comments · Fixed by #346

Comments

@TimB1023
Copy link

As a test that I had installed things correctly, I ran the example program here: https://github.com/p5py/p5

The program runs exactly as shown in the gif, but:

  • Keywords related to the mouse are underlined and described as having an unresolved reference. Importing the reference is not offered as an option.
    -Lots of errors are generated when I run the code.
    I'm using:
  • PyCharm 2021.3.2 Community edition on Windows 10 as my editor
  • python 3.10.4
  • p5 0.7.1
  • I also tried running the code in IDLE 3.10.4.

See below for code and error messages from PyCharm and IDLE below.
Thank you!

======= Code =========
(as copied form github)
from p5 import *

def setup():
size(640, 360)
no_stroke()
background(204)

def draw():
if mouse_is_pressed:
fill(random_uniform(255), random_uniform(127), random_uniform(51), 127)
else:
fill(255, 15)

circle_size = random_uniform(low=10, high=80)

circle((mouse_x, mouse_y), circle_size)

def key_pressed(event):
background(204)

run()
===== Error messages, PyCharm =====
C:\Users\tim\PycharmProjects\Processing\venv\Scripts\python.exe C:/Users/tim/PycharmProjects/Processing/main.py
WARNING: Traceback (most recent call last):
File "C:\Users\tim\PycharmProjects\Processing\main.py", line 21, in
run()
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\p5\sketch\userspace.py", line 155, in run
p5.sketch = Sketch(setup_method, draw_method, handlers, frame_rate)
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\p5\sketch\base.py", line 60, in init
app.Canvas.init(
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\vispy\app\canvas.py", line 211, in init
self.create_native()
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\vispy\app\canvas.py", line 228, in create_native
self._app.backend_module.CanvasBackend(self, **self._backend_kwargs)
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\vispy\app\backends_glfw.py", line 298, in init
self._on_resize(self._id, size[0], size[1])
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\vispy\app\backends_glfw.py", line 394, in _on_resize
self._vispy_canvas.events.resize(
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\vispy\util\event.py", line 453, in call
self._invoke_callback(cb, event)
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\vispy\util\event.py", line 471, in _invoke_callback
_handle_exception(self.ignore_callback_errors,
<< caught exception here: >>
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\vispy\util\event.py", line 469, in _invoke_callback
cb(event)
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\p5\sketch\base.py", line 157, in on_resize
p5.renderer.reset_view()
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\p5\sketch\renderer2d.py", line 82, in reset_view
self.texture_prog['modelview'] = self.modelview_matrix.T.flatten()
TypeError: 'NoneType' object does not support item assignment
ERROR: Invoking <bound method Sketch.on_resize of <Sketch (Glfw) at 0x2a7316861d0>> for ResizeEvent
Exception ignored on calling ctypes callback function: <function CanvasBackend.on_close at 0x000002A73195C9D0>
Traceback (most recent call last):
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\glfw_init
.py", line 660, in callback_wrapper
return func(*args, **kwargs)
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\vispy\app\backends_glfw.py", line 400, in _on_close
self._vispy_canvas.close()
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\vispy\app\canvas.py", line 463, in close
self.events.close()
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\vispy\util\event.py", line 453, in call
self._invoke_callback(cb, event)
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\vispy\util\event.py", line 469, in _invoke_callback
cb(event)
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\p5\sketch\base.py", line 148, in on_close
exit()
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib_sitebuiltins.py", line 26, in call
raise SystemExit(code)
SystemExit: None
Traceback (most recent call last):
File "C:\Users\tim\PycharmProjects\Processing\main.py", line 21, in
run()
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\p5\sketch\userspace.py", line 167, in run
exit()
File "C:\Users\tim\PycharmProjects\Processing\venv\lib\site-packages\p5\sketch\userspace.py", line 250, in exit
p5.exit(*args, **kwargs)
AttributeError: module 'p5.core.p5' has no attribute 'exit'

Process finished with exit code 1

===== Error Messages, IDLE =====
WARNING: Traceback (most recent call last):
File "", line 1, in
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib\idlelib\run.py", line 164, in main
ret = method(*args, **kwargs)
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib\idlelib\run.py", line 578, in runcode
exec(code, self.locals)
File "C:/Users/tim/AppData/Local/Programs/Python/Python310/test.py", line 21, in
run()
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\userspace.py", line 155, in run
p5.sketch = Sketch(setup_method, draw_method, handlers, frame_rate)
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\base.py", line 60, in init
app.Canvas.init(
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\app\canvas.py", line 211, in init
self.create_native()
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\app\canvas.py", line 228, in create_native
self._app.backend_module.CanvasBackend(self, **self._backend_kwargs)
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\app\backends_glfw.py", line 298, in init
self._on_resize(self._id, size[0], size[1])
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\app\backends_glfw.py", line 394, in _on_resize
self._vispy_canvas.events.resize(
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\util\event.py", line 453, in call
self._invoke_callback(cb, event)
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\util\event.py", line 471, in _invoke_callback
_handle_exception(self.ignore_callback_errors,
<< caught exception here: >>
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\util\event.py", line 469, in _invoke_callback
cb(event)
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\base.py", line 157, in on_resize
p5.renderer.reset_view()
File "C:\Users\tim\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\renderer2d.py", line 82, in reset_view
self.texture_prog['modelview'] = self.modelview_matrix.T.flatten()
TypeError: 'NoneType' object does not support item assignment
ERROR: Invoking <bound method Sketch.on_resize of <Sketch (Glfw) at 0x28636a93430>> for ResizeEvent

@github-actions
Copy link
Contributor

Thank you for submitting your first issue to p5py

@discohead
Copy link

discohead commented Apr 26, 2022

Same issue here on macOS 11.6.5, running the example from the README

/Users/username/PycharmProjects/pythonProject/venv/bin/python /Users/username/PycharmProjects/pythonProject/main.py
WARNING: Traceback (most recent call last):
  File "/Users/username/PycharmProjects/pythonProject/main.py", line 62, in <module>
    run()
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/p5/sketch/userspace.py", line 155, in run
    p5.sketch = Sketch(setup_method, draw_method, handlers, frame_rate)
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/p5/sketch/base.py", line 60, in __init__
    app.Canvas.__init__(
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/vispy/app/canvas.py", line 211, in __init__
    self.create_native()
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/vispy/app/canvas.py", line 228, in create_native
    self._app.backend_module.CanvasBackend(self, **self._backend_kwargs)
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/vispy/app/backends/_glfw.py", line 298, in __init__
    self._on_resize(self._id, size[0], size[1])
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/vispy/app/backends/_glfw.py", line 394, in _on_resize
    self._vispy_canvas.events.resize(
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/vispy/util/event.py", line 453, in __call__
    self._invoke_callback(cb, event)
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/vispy/util/event.py", line 471, in _invoke_callback
    _handle_exception(self.ignore_callback_errors,
  << caught exception here: >>
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/vispy/util/event.py", line 469, in _invoke_callback
    cb(event)
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/p5/sketch/base.py", line 157, in on_resize
    p5.renderer.reset_view()
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/p5/sketch/renderer2d.py", line 82, in reset_view
    self.texture_prog['modelview'] = self.modelview_matrix.T.flatten()
TypeError: 'NoneType' object does not support item assignment
ERROR: Invoking <bound method Sketch.on_resize of <Sketch (Glfw) at 0x17e9005e0>> for ResizeEvent
Traceback (most recent call last):
  File "/Users/username/PycharmProjects/pythonProject/main.py", line 62, in <module>
    run()
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/p5/sketch/userspace.py", line 166, in run
    app.run()
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/vispy/app/_default_app.py", line 60, in run
    return default_app.run()
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/vispy/app/application.py", line 160, in run
    return self._backend._vispy_run()
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/vispy/app/backends/_glfw.py", line 187, in _vispy_run
    while any(w._id is not None and not glfw.window_should_close(w._id)
  File "/Users/username/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/vispy/app/backends/_glfw.py", line 187, in <genexpr>
    while any(w._id is not None and not glfw.window_should_close(w._id)
KeyboardInterrupt

Process finished with exit code 130 (interrupted by signal 2: SIGINT)

@ccolas
Copy link

ccolas commented Jun 1, 2022

Hi, any update on this?

@ahdistefano
Copy link

Same issue here with p5 0.7.1 on Python 3.6.8

@quoellfrisch
Copy link

Same issue p5 0.7.1 on Python 3.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants