22
$\begingroup$

I don´t understand why I get this error message:

Python script fail, look in the console for now

I only put this piece of code in the scripting window:

import bge
bge.render.drawLine([0,0,0],[10,10,10],[255,40,0])

Is supposed I get error information from the console? Because I dind´t get it.

enter image description here

$\endgroup$

2 Answers 2

19
$\begingroup$

You will need to open the system console, which is found by going to the Window menu at the top and choosing Toggle System Console. Do note that closing the console via the X button at the top right will close Blender as well, so if you want to close the console use the Toggle System Console menu option again.

EDIT: I just tried the code you have and it works fine. I think your issue is how you are trying to execute the code. To execute this code in the BGE you will need to have an object that has a sensor (such as an always sensor with true level triggering enabled) connected to a python controller with your script selected.

Then play your game and you will see your line. Simply running the script via the text editor will cause it to fail.

$\endgroup$
4
  • $\begingroup$ I click on "Toggle System Console", as you advise me, and appears a window with the title of "Blender", but it don´t give me any information about the error. $\endgroup$
    – Mr. Baldan
    Jan 6, 2018 at 19:01
  • $\begingroup$ Sorry, It´s true...I see error information on the window that appears when I click on "Toggle System Console". In this case the information is: ImportError: No module named "bge". $\endgroup$
    – Mr. Baldan
    Jan 6, 2018 at 19:07
  • 14
    $\begingroup$ There is no Window -> Toggle System Console entity in Blender $\endgroup$
    – Dims
    Jul 21, 2019 at 19:58
  • $\begingroup$ i use Blender 2.83 and i found that Window > Toggle System Console .. $\endgroup$
    – risnandar
    Jan 10, 2021 at 7:48
13
$\begingroup$

For the people saying that "There is no Window -> Toggle System Console entity in Blender". Then I presume you are on macOS or Linux and will have to open Blender from your systems terminal.

On macOS you would

  1. Find Blender.app
  2. Right click and show package content
  3. Navigate to "Contents/MacOS/"
  4. Drag the "Blender" file into a terminal window
  5. Press enter to start, your output will now be seen in that window.

On Linux:

cd /usr/share/applications

gtk-launch blender.desktop

$\endgroup$
3
  • 3
    $\begingroup$ It would be a great interface enhancement to have those messages easily visible for people launching the application "as usual" (from the standard shortcut) on those platforms... $\endgroup$
    – villares
    Oct 11, 2020 at 20:40
  • $\begingroup$ I guess the Linux instruction here is assuming that Blender was also installed via terminal. If you downloaded the tar.xz from Blender.org and uncompressed it you can then navigate to the folder and run ./blender $\endgroup$
    – chicOrtiz
    Apr 7, 2021 at 18:57
  • $\begingroup$ On MacOS, you can also just launch the application from a terminal. Pull up a terminal, then: /Applications/Blender.app/Contents/MacOS/Blender (assuming it's in your /Applications folder) $\endgroup$
    – Jan
    May 13, 2021 at 3:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .