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.
Related
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.
Is there an easy way to pre-"compile" the entire Python standard library to byte code? If so, would this also guarantee that Python never re-"compiles" a file if a corresponding .pyc file already exists (as long as the standard library is not updated or modified)?
Background: On an application server, Python sometimes spontaneously goes into a broken state that manifests itself like this:
C:\> python
Traceback (most recent call last):
File "C:\Python27\lib\site.py", line 563, in <module>
main()
File "C:\Python27\lib\site.py", line 552, in main
aliasmbcs()
File "C:\Python27\lib\site.py", line 478, in aliasmbcs
enc = locale.getdefaultlocale()[1]
AttributeError: 'module' object has no attribute 'getdefaultlocale'
and that can be resolved by re-installing Python. Someone else told me that he has seen corrupted (0-byte) .pyc files and that deleting those solved the problem. However, I cannot reproduce the issue by deliberately creating 0-byte .pyc files.
I don't like the fact that files belonging to the standard library are "compiled" to byte code on demand, as this happens within a process running both Python and native code that can crash unexpectedly. I would prefer to have all Python code pre-compiled, whether or not it helps to resolve the above situation.
Make the system .pyc files read-only, even for administrator. This should prevent Python from modyfing them unnecessarily.
If You're on Windows go to properties → security → edit, and deny all privileges for all groups.
I have a working windows service which is referencing a custom schema created in SQLAlchemy. Before moving everything into a seperate module, everything was working just fine in python form, exe form, and msi form.
I have never imported custom modules before. Right now, I am staticly loading the path of the module into the application. And it seems to work just fine.
Now I moved the code out, set up an import did some work, and my config file is failing to load! I can't figure it out!
The static load --
`sys.path.insert(0,r"c:\dev\nbc_dps_tools\dashboardtotal\schema")
from NydpsSchema import Computer, Drive, Workgroup
`
Seems to get me all the objects I need. Figuring out how to dynamically load the path will be done after I figure out the following pathing problem.
service_dir = os.path.dirname(os.path.realpath("__file__"))
yaml_file = os.path.join(service_dir, 'configs.yaml')
Printing the yaml_file path from above gives me the following path in console, when starting the service
However, after the service starts (successfully) it quickly dies out. Providing the following error in event viewer.
Python could not import the service's module
Traceback (most recent call last):
File "c:\dev\nbc_dps_tools\dashboardtotal\Logon_Service_Live\Logon_Service.py", line 82, in <module>
stream = open(yaml_file, 'r')
FileNotFoundError: [Errno 2] No such file or directory: 'c:\\Python34\\lib\\site-packages\\win32\\configs.yaml'
%2: %3
As we see, while installing/starting the service, it resolves properly, gets the config file, and starts. However, once it starts, it appears as if the yaml_file path is resolving to win32 site-package. I tried lots of different pathing styles, nothing seems to work.
The idea is that the path should resolve properly whether run from .py, .exe (or msi)
Thanks for reading, if any additional information is required to help, I can always add more.
EDIT : It appears it is resolving to pythonservice.exe, and not to the script
I'm getting the error:
Traceback (most recent call last):
File "/Volumes/Sublime Text/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 549, in run_
return self.run(edit)
File "HaxeComplete in /Users/graphic/Library/Application Support/Sublime Text 3/Installed Packages/Haxe.sublime-package", line 338, in run
File "HaxeComplete in /Users/graphic/Library/Application Support/Sublime Text 3/Installed Packages/Haxe.sublime-package", line 925, in run_build
TypeError: 'NoneType' object is not iterable
In the console when I try to build my project. Is this a permissions issue or something? I'm unable to find much about it online when I search. I've tried different build targets to no avail, and I got the same error in Sublime Text 2.
As an important side note, the Build option in the menu is greyed out, and when I try to run it via keyboard shortcut I get "No Build System".
This problem appeared to boil down to a combination of two things:
I made sure to get the latest version of Haxe and Haxelib.
When I tried to trigger a build from Sublime Text 3, I had to make sure to have the project's build XML file open and active. Once it was the active file, I'd then choose a build target and start the build. After it had built successfully, I could change the active file and still complete a build, but sometimes it would appear to "forget" and I'd have to go back to the XML file, choose a build target, and trigger the build once again from the build XML file.
I have a project written in Python 2.7 and PyGTK, with py2exe for compiling. I have two modules, "Launchpad.py" and "RegistrationScreen.py". I need to open RegistrationScreen.py from Launchpad.py.
I am using the following code currently:
def open_registration(event, data=None):
subprocess.Popen(["python", "RegistrationScreen.py"])
This works fine when I test - the window is opened without the shell window opening.
However, when I compile using py2exe, I get the following log error on executing the created application.
Traceback (most recent call last): File "Launchpad.py", line 26, in
open_registration File "subprocess.pyc", line 672, in init
File "subprocess.pyc", line 882, in _execute_child WindowsError:
[Error 2] The system cannot find the file specified
How do I fix my code so py2exe will compile it correctly? Is there another way I can open the RegistrationScreen.py module's window from Launchpad.py, that won't throw errors in the final .exe file?
The problem is the path. RegistrationScreen.py is (probably) compressed inside dist/library.zip, but your code that calls it is looking for it in dist/RegestrationScreen.py.
I don't know what the best solution to this is... py2exe is kind of a pain for accessing files.
Also, you probably don't want to be doing subprocess.Popen(["python", "RegistrationScreen.py"]) because you can't guarantee your users will have python installed and accessible systemwide. If you really need a separate process, then maybe you should run py2exe on RegistrationScreen.py individually to create a separate .exe, and then include that in the dist folder of your main .exe?
I know that's somewhat convoluted, but it would probably work. And as I said, there might be a better way.