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

Possibly outdated dependency #417

Closed
theafox opened this issue Feb 7, 2023 · 7 comments · Fixed by #435
Closed

Possibly outdated dependency #417

theafox opened this issue Feb 7, 2023 · 7 comments · Fixed by #435

Comments

@theafox
Copy link

theafox commented Feb 7, 2023

After following the installation process described here, I received a RuntimeError stating Could not import glwf, you may need to `pip install glfw` first. even though glfw was installed both via brew and via pip (through the p5 dependencies).

To Reproduce
glfw has been installed via brew beforehand.

$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install p5
$ python3
>>> import glfw
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/.../venv/lib/python3.10/site-packages/glfw/__init__.py", line 41, in <module>
    raise ImportError("Failed to load GLFW3 shared library.")
ImportError: Failed to load GLFW3 shared library.
>>> exit()
$ pip3 uninstall glfw
$ pip3 install glfw
$ python3
>>> import glfw
>>> exit()

This example just imports glfw without using p5, however I tried running the example in the tutorial at first, which is how I ran into this problem. In that case the error looks as follows:

Traceback (most recent call last):
  File "/Users/.../test.py", line 14, in <module>
    run()
  File "/Users/.../venv/lib/python3.10/site-packages/p5/sketch/userspace.py", line 187, in run
    vispy.use("glfw")
  File "/Users/.../venv/lib/python3.10/site-packages/vispy/util/wrappers.py", line 93, in use
    use_app(app)
  File "/Users/.../venv/lib/python3.10/site-packages/vispy/app/_default_app.py", line 47, in use_app
    default_app = Application(backend_name)
  File "/Users/.../venv/lib/python3.10/site-packages/vispy/app/application.py", line 47, in __init__
    self._use(backend_name)
  File "/Users/.../venv/lib/python3.10/site-packages/vispy/app/application.py", line 240, in _use
    raise RuntimeError(msg)
RuntimeError: Could not import backend "Glfw":
Could not import glwf, you may need to `pip install glfw` first.

with test.py as:

from p5 import *

def setup():
    size(200, 200)

def draw():
    rect_mode(CENTER)
    rect((100, 100), 20, 100)
    ellipse((100, 70), 60, 60)
    ellipse((81, 70), 16, 32)
    ellipse((119, 70), 16, 32)
    line((90, 150), (80, 160))
    line((110, 150), (120, 160))
run()

System information:

  • p5 release: 0.8.2 - current version via pip
  • Python version: Python 3.10.9
  • Operating system: macOS Ventura - Version 13.1

Additional context
I also tried to reproduce the problem without a virtual environment using pip3 install p5 --user which resulted in the same problem.

I hope I did not mess up any installations or missed something and thank you in advance!

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2023

Thank you for submitting your first issue to p5py

@tushar5526
Copy link
Member

Can you redo the setup on a fresh python virtual environment? I don't have a MAC with me to test this.

@theafox theafox closed this as completed Feb 7, 2023
@theafox
Copy link
Author

theafox commented Feb 7, 2023

I accidentally misclicked with my last comment and closed the issue,
here is a screenshot of the setup,
Screenshot 2023-02-07 at 06 35 06
or would you have me use a global pip3 install p5 --user?
Here would be the second part, the reinstallation of glfw:
Screenshot 2023-02-07 at 06 44 14

@theafox theafox reopened this Feb 7, 2023
@tushar5526
Copy link
Member

I am a bit confused. In the second picture, you can import the glfw ? It should work fine then. What is the error after that ?

@theafox
Copy link
Author

theafox commented Feb 8, 2023

Well, it only works after manually updating glfw to version 2.5.6.
If you try to use the version installed alongside p5 (version 1.11.2) it does not work, hence the first error. Even if you had a later version of glfw installed beforehand, the version requirement for 1.11.2 in requirements.txt reinstalls the older version, which means installing p5 will inevitably lead to this problem. (At least for users with the same OS and OS-version as me)
I included the second part, the version update, as a possible solution to this problem, not as part of the problem. I apologise if this caused confusion, I should have been clearer about that when opening the issue.

@tushar5526
Copy link
Member

I will take a look into this. We have tests setup for all python versions so tests should be failing if this was a dependency issue. Maybe this is something specific to Mac, but this would require a much more deep dive.

@anandr86
Copy link

anandr86 commented Jun 5, 2023

This issue happened to me as well. Looks a library path problem fixed in glfw >= 2.4.0. Link to the related issue:
FlorianRhiem/pyGLFW#57

tushar5526 added a commit that referenced this issue Jun 5, 2023
Closes #417 Bump dependency
tushar5526 added a commit that referenced this issue Jun 5, 2023
* Update requirements.txt

Closes #417 Bump dependency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants