Need help to understand how the app packed by py2app works - python

I'm using py2app to package my Python code(Tkinter app), but I'm facing a very strange problem.
I have two Macs, they both have an intel CPU, and they both have the same python version 3.9.8 installed. I packed my App on Mac1 using py2app, it works totally fine. However, on my another Mac2, if I run ./dist/MyApplication.app/Contents/MacOS/MyApplication in the terminal, it works totally fine as well, but if I run ./dist/MyApplication.app directly, it still works, I mean I can still open my App, but some functions will report an error. In addition, if I run the python code on Mac2, it also works totally fine.
I'm sorry I can't provide a reproducible example, but can someone give me a hint or any idea what is going on? How I can debug this issue? Thanks for your help.

Related

GitHub Coptilot does not work in NeoVim when editing Python

I have Arch Linux and so the latest NeoVim release is installed (0.7.0 at this moment). About a month I started using GitHub Copilot and it worked well in Bash, SH, JS and others. Yesterday I wanted to rewrite some program in Python but Copilot didn't work. Tried it in different files and languages - works everywhere but not Python! :Copilot status shows "Copilot: Enabled and online", but gives no suggestions. :Copilot panel shows "Synthesizing 0/10 solutions (Duplicates hidden)". :Copilot log contains nothing. I remember that some time ago it worked as expected but now it does not. I don't have any ideas why is that happening. As an Arch user I reject VisualStudio Code and other IDEs and prefer working in terminal. Anything that may help?
Edit: just discovered that opening a file without .py and printing #!/usr/bin/env python3 works for Copilot, but in this case there's no syntax highlight. Reopening with :edit adds colors but breaks Copilot
I've just solved it on my machine. I used nvm to set my NodeJS back to v16.13.0. reloaded neovim. Copilot now working as expected.
Copilot was not working on NodeJS v18.0.0.
What's annoying is tim-pope doesn't have the issues section active on the repo. So I'm sure others will run into this. Let me know if this solves it for you.

Getting "Premature end of script headers" on Dreamhost Python Webpage

I have a webpage made in Python Flask with Python 2.7 (I know), hosted on Dreamhost. Up until a few days ago I had absolutely no problems. Then, I started getting a permission error on my page. I don't know what happened, but I got with Dreamhost live chat and they solved it by doing a chmod 755 to my files. Everything was working again, but on further inspection, all the parts that generate a PDF document in my webpage have stopped working. The error that I am getting in the error logs is "Premature end of script headers".
This error only appears whenever I try to generate a PDF. The code works perfectly on my local environment, but it does not work on the hosting. I got with the people of Dreamhost again and they said that it was nothing on their side. Which is weird considering that the code that was ALREADY WORKING was not changed at all. I tried debugging on my part but I am not getting any errors.
I have tried pretty much everything I can think of to solve this situation but I have been unsuccessful. The course of action is to change this hosting (it was a mistake on my part to use Dreamhost in the first place, I know. But when I made this I was just starting and I had very little knowledge). But I need a quicker solution for the moment, and I was wondering if anyone has had this problem and could maybe help me out with this.
To elaborate, I am using Python 2.7, the library that is used for the PDF creation is Flask-Weasyprint (0.5). I tried running the wsgi file myself, and I am getting the following message:
/path/to/local/lib/python2.7/site-packages/WeasyPrint-0.39-py2.7.egg/weasyprint/text.py:29: UserWarning: There are known rendering problems with Cairo <= 1.14.0
warnings.warn('There are known rendering problems with Cairo <= 1.14.0')
/path/to/local/lib/python2.7/site-packages/WeasyPrint-0.39-py2.7.egg/weasyprint/fonts.py:46: UserWarning: #font-face support needs Pango >= 1.38
warnings.warn('#font-face support needs Pango >= 1.38')
I know that I should change to Python 3. When I made this web app, Dreamhost only accepted Python 2 and I barely had any knowledge of creating VPS or something like that. It is my plan to change hosting soon to a virtual machine and to run the project in Python 3. But I need a solution for this now before I go on.
Any help will be appreciated. If you need more details please let me know.
This may be due to the Passenger file not including your project directory in its path. One solution is adding the following to your passenger_wsgi.py file:
sys.path.append(os.getcwd()+"/<project_name>")

PyInstaller app gets caught by SmartScreen

I made a program for people at work that simply takes csvs, converts them, and turns them into a csv that can be read by a different program and I have made the program in Python. Everyone here uses Windows so I originally used py2exe to make an exe and it worked fine for everyone.
Recently, I made some changes to the code to use the newest Python version which py2exe does not support so I used pyinstaller which worked great. However, when I passed it on to a few people at the office to test it, Windows SmartScreen caught it and the Anti-Virus program quarantined it for 3 hours. Obviously this is not ideal. What can I do to not make SmartScreen catch it? And why would py2exe not trigger the same warnings?
SmartScreen show this warning for executables that are not popular and unfortunately Microsoft does't give a certain number of downloads to SmartScreen stop triggering out.

pip "pyrax" dependency with iron worker

I created a Python script to use Rackspace's API (Pyrax) to handle some image processing. It works perfect locally, but when I upload it to Iron.io worker, it builds but does not import.
I am using a Windows 8 pc, but my boss runs OS X and uploading the exact worker package, it works fine. So I'm thinking it's something with Windows 8 but I don't know how to check/fix.
I do apologize in advance if I ramble or do not explain things clearly enough but any help would be greatly appreciated.
My worker file looks like this:
runtime "python"
exec "rackspace.py"
pip "pyrax"
full_remote_build true
Then I simply import pyrax in my python file.
I figured out that it was a bad Ruby install. No idea why, but reinstalling it worked.
It's difficult to know for sure what's happening without being able to see a traceback. Do you get anything like that which could be used to help figure out what's going on?

Outputed py2exe exe won't run only when signed: ImportError

So, I've got a program I made in python 2.6, it ran fine as normal python, and ran fine when made into an exe via py2exe v0.6.9. I used signtool to sign it, having changed nothing else, and it stops working.
When I run the signed exe, I receive an "ImportError: No module named os" from line 1 of my script. I did some digging and found this: http://osdir.com/ml/python.py2exe/2008-04/msg00031.html, which seems to be a very close description of my problem. I manually applied the patch linked to from the py2exe website to my build_exe.py file, though I was running py2exe 0.6.9 instead of 0.6.6, so I tried to take that into account. Still no love.
According to the link, this seems to be a py2exe issue. I don't know though. Any help would be much appreciated. And of course, I'll answer any other questions I can that you have about this. Thanks for the help!
If it's a py2exe issue, maybe give the newer PyInstaller a shot to build your executable. It's in active development, unlike py2exe which apparently hasn't been updated since 2008-11-16.

Categories