PyOpenGL: glCreateProgram() causes NullFunctionError - python

I am just trying to run exactly this sample code to test the installation: https://gist.github.com/ousttrue/c4ae334fc1505cdf4cd7
It fails on glCreateProgram() eventhough i have instaled PyOpenGL, PyOpenGL-accelerate and freeglut using the whl files from here: https://www.lfd.uci.edu/~gohlke/pythonlibs/
Error:
File "C:\Program Files (x86)\Python\Python35\lib\site-
packages\OpenGL\platform\baseplatform.py", line 410, in __call__
self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function
glCreateProgram, check for bool(glCreateProgram) before calling
The Code from this tutorial which does not include a shader works just fine: https://noobtuts.com/python/opengl-introduction
So it is just glCreateProgram() that fails.
I have also copied the DLL files into SystenWOW64 and System32, as well as the folder my Script runs in.
Has anyone an idea where to search for the error.
I run Windows 10 64 Bit with 64 bit Python 3.5 via Remote Desktop

The problem was that, when you log in on remote desktop you somehow can't access the graphics card. Connecting the screen directly to the computer solved the problem.

Related

Inconsistent behavior of pyserial and rshell when executed in a .py file

I am trying to program my lego mindstorms inventor robot using python and this pypi package. It basically uses rshell to communicate with the lego robot that is running micropython. Here is the code that I am trying to execute.
from mindstorms import Hub
hub = Hub()
motor = hub.port.E.motor
print(motor)
motor.run_for_degrees(270)
When I run this code line by line in the python shell in the terminal everything works as expected. The motor turns. However, if I put this in a .py file, I get this error. rshell.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\n File "<stdin>", line 1, in <module>\r\nAttributeError: \'NoneType\' object has no attribute \'run_for_degrees\'\r\n'
Seems like the issue is that the motor is not being detected by the brain when I run the script in a .py file.
I made another script for diagnostics. It is sending messages directly to the robot without using the pypi package.
board = Pyboard(device)
board.enter_raw_repl()
print(board.exec_("import hub;print(hub.port.A.info())"))
The result is "None". The brain by itself is detected because commands such as print(board.exec_("import hub;print(hub.info())")) run successfully. When I am trying to get any information about the port, the result is None, which makes me believe that the connected motor is not detected by the .py file. Again, if I simply run all this code in the python shell it works perfectly. I am confused by this irregular behavior.
Here are the steps that I took to troubleshot this(none of them worked):
Tried to run a .py file from the terminal using exec() function, and still get the error that the motor is None.
Checked that the python version of the shell and the version of the python that is running the .py file is the same.
Running this script on different machines.
Reinstalled lego mindstorms firmware and ensured that the latest version is running.
Any suggestions why this would this problem occur?
The issue is that you need to wait a few seconds after the initialization of the Mindstorms brain before performing any kind of motor initialization.
from mindstorms import Hub;
import time
hub = Hub();
time.sleep(2)
print(hub.port.A.motor);
hub.port.A.motor.run_for_degrees(30);

Setup file cannot be installed on other computers

I created an installer file using nsis. After running the programme on my system, it worked flawlessly but when installed on third party system, it complained on launching the app.
Traceback (most recent call last):
File "Classify.py", line 20, in <module>
File "tkinter\_init_.py", line 2109, in wm_iconbitmap
_tkinter.TclError: bitmap "D:\Users\Engr M2J\Documents\GitHub\HAM1000-Image-Classifier\logo.ico" not defined
I know this is where the error is coming from;
root.title("HAM10000 Image Classifier by Engr. Sule Muhammed Abba- BookNowNow Code version 1.1.0")
root.iconbitmap(r'D:\Users\Engr M2J\Documents\GitHub\HAM1000-Image-Classifier\logo.ico')
it is actually referencing my computer path instead of it to be relative. This is the only way I could get the icon to load by using it direct path. whenever I use the below code, I get the error that follows;
root.iconbitmap('logo.ico')
I get this error
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
_tkinter.TclError: bitmap "logo.ico" not defined
Please assist
Here are the steps taken to solve the problem.
I printed the working directory.
print(getcwd())
I then copied all code files to this directory
By doing this, I was able to load the icon using
root.iconbitmap(r'logo.ico')
My new software now runs seamlessly on different systems without any complain.
Any better solution is welcome but this will work perfectly.

Python execute file is not a valid Win32 application on Windows 2000

I am using Win7 (64 bit) to create simple Python script as “helloworld.py” then create executable file by using PyInstaller as command “pyinstaller helloworld.py --onefile”. helloworld.exe is created under “dist” folder. After that, I tried to test it by using DOS command line "call helloworld.exe". It shows good result “helloworld” message as expectation.
Then I copied helloworld.exe to my target machine Windows 2000 and call helloworld.exe to test it but found the error dialog with message “C:\dist\helloworld.exe is not a valid Win32 application.”
Anyone can help to advise me to fix this problem?
Python3.8.8 (32 bit)
PyInstaller4.2

Python subprocess different ouput of same call on diffrent machines

I am trying to execute a java file with python using subprocess.
I have 2 machines, both have the same windows version and same python version. Even the path for the jar file is same on both the PCs.
I am trying to do the following
import subprocess
path = "C:\\Program Files (x86)\\Microchip\\MPLABX\\v5.35\\mplab_platform\\mplab_ipe\\ipecmd.jar"
subprocess.call(["java", "--jar", path])
This works on one PC but throws a FileNotFoundError on the other.
My first doubt was that it was because of spaces in the file path. But now after it worked on one, I am clueless.
Images attached for reference
Update
So, problem was that the other machine did not have java. After installing it, I tried to tun the jar file from the command line which works. But on running it from the python script, it throws WinfError 193 (Image attached).
On referring it from here, it says, 193 stands for
ERROR_BAD_EXE_FORMAT
193 (0xC1)
%1 is not a valid Win32 application.
Now again the question is, if this can be executed from cmd, why is it causing problems when done with Python ?

How to use websockify with python on windows or compiling websockify as windows executable (for more multiple client connection at a time)

I'm trying to get the websockify 0.6.0 running on windows but without any luck,
I have tried python websockify.py 1501 10.0.0.141:1501 but its not good, getting errors , like that:
Traceback (most recent call last):
File "websockify.py", line 1, in <module>
run
NameError: name 'run' is not defined
I also tried Compiling Websockify as Windows Executable , but this also didn't work
I use the following command run.exe 1501 10.0.0.141:1501 and it looks promising at the beginning, outputting the following to the console:
WARNING: no 'resource' module, daemonizing is disabled
WebSocket server settings:
- Listen on :1501
- Flash security policy server
- No SSL/TLS support (no cert file)
- proxying from :1501 to 10.0.0.141:1501
but then after trying to connect using the following from the browser ws://localhost:1501
**it outputs the following error
Traceback (most recent call last):
File "run", line 5, in <module>
File "websockify\websocketproxy.pyc", line 419, in websockify_init
File "websockify\websocket.pyc", line 1018, in start_server
UnboundLocalError: local variable 'exc' referenced before assignment
Any idea on how to use the websockify on windows / or how to use the compiled websockify as windows executable ?
The easiest way to get websockify working on Windows is to use the Node.js version of websockify (in the other/js directory). It works perfectly out of the box, with no shenanigans required.
To address this, use the modified following commands for your example source, start from the beginning of each step and see if it helps:
Firstly, install Portable Python 2.7
You then need to modify the setup.py (It looks like this is why you are getting your first error, as you may not have defined run):
from setuptools import setup, find_packages
# add (line 2):
import py2exe
setup(name=name,
# add (line 10):
console=['run'],
Ensure the above has executed correctly by inspecting setup.py and ensure it includes run.
In your local code, import the resources module to allow you to monitor, measure and control system resources utilized by your program
import resource
Inspect your local variable exc and ensure you have assigned a value to it before calling it (I'm guessing you may have attributed a system variable to it, but python was unable to do so as you did not have resources imported, and as such it was not assigned). If you like, put up an example of your code in the comment to this response and I'll take a closer look at this part.
Back to your source guide, navigate to the websockify folder in command prompt, then execute the following to compile websockify:
[Your path to Portable Python install]\App\python.exe setup.py py2exe --includes numpy
You will now see in the websockify directory a new dir 'dist' which contains the compiled exe. An example provided is:
run.exe 5901 localhost:5900
There is also a guide here to run websockify as a Windows Service if this suits (again mentioned in your source).
----Further edit for more detail----
Open up the two files that seem to be giving you issues (websockify\websocketproxy.pyc and websockify\websocket.pyc and ensure that any reference to a variable called "exc" is referenced after it has been assigned a value (small chance of an issue if you have not yet modified these files.
I believe that your code is relying upon making and monitoring changes to the system resources (such as ports etc) and you are not allowing your code to have these permissions, so it needs the resources module. If you are calling run.exe from a program (what I called your local code) then you need to import resources at the top. If you are just straight up calling the run.exe program from a command line, then try making this new program and see if this helps. If not, send me the contents of your websockify folder and run.exe and I will take a look
# Program Name: goAndRun.py
# Code:
import sys, string, os, arcgisscripting, resource
os.chdir( 'C:\\[Path_to_the_dir_containing_run.exe]' )
os.system( '"C:\\[Path_to_the_dir_containing_run.exe]\run.exe, 5901 localhost:5900"' )
And then use the command:
python goAndRun.py
Not being in your environment, I cannot tell if this will execute exactly as I have written it. The last line may also be:
os.system( '"C:\\[Path_to_the_dir_containing_run.exe]\run.exe"', '5901 localhost:5900' )

Categories

Resources