#๐Ÿ”’ python not recognising functions from modules (functions i know exist) from time to time

10 messages ยท Page 1 of 1 (latest)

half sedge
#
PS C:\Users\elise\Documents\Python\PixKarts> python3 .\main.py
Traceback (most recent call last):
  File "C:\Users\elise\Documents\Python\PixKarts\main.py", line 18, in <module>
    init_window(800, 600, "PixKarts")
    ^^^^^^^^^^^
NameError: name 'init_window' is not defined

i am using pyray module

this issue seems to fix itself after a while because yesterday i had the same problem but with pygame. its kind of a shame because i cant run my code when it does this.

next citrusBOT
#

@half sedge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

half sedge
#

i have imported pyray:

#
from pyray import *
#

fyi theres a pyray PyPI package but i am using the raylib package. raylib is imported as pyray.

eager yoke
#

overall you really should avoid import *

#

try just ```py
import pyray
pyray.init_window(100, 100, 'test')

pastel lodge
#

import * imports the public names unless the module implents an __all__ name, in why case you only get what it says.

You could just import the names you need, eg:

from pyray import init_window, name2, name3, ...
next citrusBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.