Py2App - PyQt5 using wrong port_v# - python

I was building a simple GUI I made with PyQT5, and everything works fine during development build using py2app. When I go to to build the .app file, however I get a crash in the PyQt5 code:
File "/usr/local/lib/python2.7/site-packages/PyQt5/uic/port_v3/ascii_upper.py", line 24, in <module>
_ascii_trans_table = bytes.maketrans(b'abcdefghijklmnopqrstuvwxyz',
AttributeError: type object 'str' has no attribute 'maketrans'
I've traced this down to what seems to be PyQt5 trying to run python 3 code from the port_v3 module, however I am doing everything in 2.7, and I can't figure out why it's trying to load Python 3 when it gets to building the PyQt portion of the app. Any ideas how to track this down or a workaround?

After digging around and watching py2app take forever, seemingly trying to package every module installed on my machine for a simple app, I abandoned py2app altogether. I went with pyinstaller instead and it worked like a charm. Quick build and everything worked fine with all the dependencies for python 2.7.13 and PyQt5.
I know this isn't a solution to my original question about py2app, but still solved the original problem of trying to get an .app file bundled, so anyone else having this issue with py2app, I'd suggest trying pyinstaller.

Related

importing dlls with pythonnet in spyder

I have a python package that acts like a wrapper for a .dll written in C#. The binary is imported into python by the pythonnet package. Thus, the user can access the functionality of the so called cs_backend.dll conveniently from the python side. The import looks as follows:
import clr as __clr
import System as __System
__clr.AddReference(PATH_TO_CS_BACKEND + "\\cs_backend")
import cs_backend as __csb # exception thrown here
However, it seems that python can't import the .dll as I get a ModuleNotFoundError: No module named 'cs_backend'.
The odd thing is that this error only occures when running the code from Spyder. Executing exactly the same code from Visual Studio Code works perfectly fine.
Do you have any idea what the problem could be?
system specifications
os: windows 10
.net framework v4.5.1
python 3.8.5
spyder 4.2.1
Edit:
I have found a github issue on the pythonnet repository that describes a similar (although not quite the same) problem. However, since it has been open for about 3 years, it seems that there is little to no progress on that.
Edit 2:
There is a similar question here on stack overflow. The solution was to install a newer .NET Framework. This is not my problem since with any IDE other than Spyder the code works just fine. Thus, I guess that this is mainly a Spyder issue.
Currently, it seems that there is neither a solution nor an effort to resolve this problem.
It looks like the problem is caused by the IPython console integrated in Spyder.
A simple workaround is to execute the python script from the system console.
In Spyder this can be done by going to Run - Configuration per file - Execute in external system console.
With the new configuration it is at least possible to run the script.

pkg_resources.DistributionNotFound for cvlib library

I have written a python script that uses cvlib library, when i run the code as a python scrept it works fine, however; when i converted the code into an exe file, everything seems to work fine, apart from importing cvlib library.
The error shows up like the follwoing:
pkg_resources.DistributionNotFound: The 'cvlib' distribution was not found and is required by the application
The detailed Error
Has anyone face this problem before ? if so, could you please provide me the proper way of fixing it as i think there are some dependencies issue.
I figured out finally what the problem was, Pyinstaller sometimes is not able to include some libraries that we import in our (.py) file. So, When Pyinstaller creates the (.exe) file, it agnores some imports, so the solution is to copy the folder of these imports, For example, cvlib forlder and paste it as it is in the same location as your (.exe) file.

Pyinstaller pythonfile.py Fatal error in launcher: Unable to create process using '"'

I am trying to convert my .py file to an exe file. I've done it in the past but for some reason it isn't working anymore. I am using Python 2.7 and have other versions installed as well but my application won't work without 2.7. If I do python activityKivy.py it runs perfectly. I also tried with py2exe but was unsuccessful, it gave me too many dll warnings and would crash each time I open it. I prefer to stick with pyinstaller because thats what always worked for me. Some help would greatly be appreciates!
error screenshot
**Update: I wasn't able to figure out exactly what the problem was but I was playing around with my environment variables and changing my pip names to pip2 pip3 and thats when this problem started happening and even when I reverted all my changes it still showed me this.I was able to fix it by simply uninstalling pyinstaller and redownloading it.

RecycleView causing Kivy executable to crash

I followed the directions in the Kivy documentation on how to package applications for Windows, but my application crashes as soon as I try to run it. The last line of the traceback suggests a problem with my RecycleView widget:
File "C:\Users\awende\AppData\Local\Continuum\Anaconda3\lib\site-packages\kivy\factory.py", line 139, in __getattr__
module = __import__(name=item['module'], fromlist='.')
ModuleNotFoundError: No module named 'kivy.uix.recycleview.__init__.'
Failed to execute script SingleTabApp
I have tried importing kivy.uix.recycleview in all my .py and .kv files that it wasn't already imported in, but this doesn't seem to be the problem. I am not sure if this is a problem with my code, or if something else is going on.
Other potentially relevant information:
I am using Python 3.6.1 with the current dev version of PyInstaller.
Kivy version 1.10.0
SingleTabApp is the name of my main Python script, and was working correctly prior to using PyInstaller.
install a recent version of cython, notice that for a version of cython there is a corresponding version of kivy. To implement RecycleView, the version of kivy in your "package apk" not your computer must be at least 1.10
I ran across the same problem with PyInstaller on Windows 7. I appied a quick fix to factory_registers.py and it worked! (https://github.com/kivy/kivy/issues/5276)
A quick fix for the issue with pyinstaller is to change e.g. r('RecycleViewBehavior', module='kivy.uix.recycleview.init') to r('RecycleViewBehavior', module='kivy.uix.recycleview').
PS factory_registers.py also has r('RecycleView', module='kivy.uix.recycleview.__init__'), I didn't touch it.

libpython3.6m.dylib vs libpython3.6.dylib

I'm working on creating an app from Python code using py2app.
Everything goes well until I run setup.py, then at the very end of it running I get this message: "ValueError:
'/Users/(my_computer_name)/anaconda3/lib/libpython3.6.dylib' does not exist"
It turns out there is a file there, just named slightly different: It asks for 'libpython3.6.dylib' and there is a file named 'libpython3.6m.dylib'
Any insight would be greatly appreciated, thank you!
Anaconda Python binaries are build with multithread support and that means the library generated will have the form *m.dylib ( see this Google Groups link )
You could create a symlink and try to build using py2app (I had issues with that).
Alternatively this worked for me: I had an equivalent virtualenv setup (which uses a Python Framework and makes py2app locate the library differently) and was able to build the application on that one.

Categories

Resources