p5 icon indicating copy to clipboard operation
p5 copied to clipboard

Error when using with Pycharm

Open GowthamKalli opened this issue 4 years ago • 9 comments

Hey I'm new to python and have been using PyCharm I have installed p5 onto pycharm using the terminal but when I try code basic stuff using mouse_x and mouse_y it says they are not defined and says RuntimeError: Could not import backend "Glfw": GLFW library not found Could I please get help

GowthamKalli avatar Jul 22 '21 17:07 GowthamKalli

Thank you for submitting your first issue to p5py

github-actions[bot] avatar Jul 22 '21 17:07 github-actions[bot]

Welcome, @GowthamKalli

You'll need to install GLFW: https://www.glfw.org/download.html

tabreturn avatar Jul 22 '21 22:07 tabreturn

Welcome, @GowthamKalli

You'll need to install GLFW: https://www.glfw.org/download.html

I have installed it it has come as a zip file Where do I extract and put the file.

GowthamKalli avatar Jul 23 '21 02:07 GowthamKalli

Refer to the instructions for your platform, here: https://p5.readthedocs.io/en/latest/install.html

tabreturn avatar Jul 23 '21 02:07 tabreturn

Refer to the instructions for your platform, here: https://p5.readthedocs.io/en/latest/install.html

Hey yeah I have seen the instructions but it says download and install but it just downloads as a zip file What and where do I have to install to get the library to work?

GowthamKalli avatar Jul 23 '21 04:07 GowthamKalli

Are you on Windows, Mac, or Linux?

tabreturn avatar Jul 23 '21 04:07 tabreturn

Are you on Windows, Mac, or Linux?

Sorry for the late reply But I am on windows And have downloaded the windows 64bit version for the pre bianaries

GowthamKalli avatar Jul 23 '21 13:07 GowthamKalli

In that download, you'll find a folder named lib-mingw-w64 (with three files in it). You can place this folder anywhere on your system. Then, as per the instructions --

"First locate the Environment Variables settings dialog box. On recent versions of Windows (Windows 8 and later), go to System info > Advanced Settings > Environment Variables. On older versions (Windows 7 and below) first right-click the computer icon (from the desktop or start menu) and then go to Properties > Advanced System Settings > Advanced > Environment Variables. Now, find and highlight the Path variable and click the edit button. Here, add the GLFW installation directory to the end of the list and save the settings."

The installation directory will look something like: \path\to\lib-mingw-w64

tabreturn avatar Jul 23 '21 22:07 tabreturn

I found this issue also. It can be solved by following:

you should import builtin or from buildin import *

import p5
import builtins

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

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

    circle_size = p5.random_uniform(low=10, high=80)
    p5.circle( ( builtins.mouse_x, builtins.mouse_y), circle_size )

def key_pressed(event):
    p5.background(204)

p5.run()

mahaidong avatar Aug 09 '21 04:08 mahaidong