How to use Kivy SDK to compile the project? - python

I'm trying to compile my first Kivy project, which is the "pong" example provided on Kivy's website. I checked the code, everything works fine when I type in "kivy main.py" in the terminal. Then I followed the instructions here (https://kivy.org/docs/guide/packaging-osx.html) to create a package for OSX (I'm assuming this is what I need next ) until this step:
"Now all you need to do is to include your compiled app in the Kivy.app by running the following command:
osx> ./package-app.sh /path/to/your/<app_folder_name>/"
But here is the problem: there is no "package-app.sh" in the directory!
And I don't have a "compiled app", isn't that what I'm trying to get, to compile my app?
If you have used Kivy before this must be a very simple problem. I'm just so new to it it's not making any sense. Please help. Also, unless there is a good reason to use buildozer instead, I'd prefer the idk. But please do explain.
Thank you!

Related

How can i turn python to apk?

I am just a newbie on that things and I want to turn python to apk with android studio or whatever. I don't really need anything to complex, I just want to open my codes output gui (I used turtle) when I open the app. Nothing else, thats all. It is probably complex process so you can just give me where to look and learn if you can't explain it all in here. Thanks!
Turtle is built around TKinter, which is a library for making desktop apps. There doesn't seem to be a way to run programs built in TKinter within Android without using some other app to run them. If you're ok with that, then you could use the solution suggested by this answer to run your code by pasting it into an app that can run Python code.

Google Translate not working with Buildozer for android kivy app

Essentially I had to import not only the libraries I use, but also the dependencies inside those libraries. httpcore is a dependency used by Google Translate library.
logcat before app crashes:
module 'httpcore' has no attribute 'SyncHTTPTransport'
At first I thought it was an issue with the version of httpcore, but specifying the version that gets downloaded normally with a pycharm terminal doesn't work either. Essentially code in Google Translate crashes when using httpcore because a specific httpcore function doesn't exist which Google Translate is using...
Why is this happening? I can't even get the libraries I download to work now either.
Edit: Based on Reddit Commenter, seems like I need to add what's called "recipes" which is a template of code added inside the python code.
Seems to be templates you need to add inside the python code: https://python-for-android.readthedocs.io/en/latest/recipes/
YouTuber NeuralNine seems to have a detailed tutorial for this, I've seen other stuff he's done and he's good. I'll give it a go after work: https://www.youtube.com/watch?v=6gNpSuE01qE

How do I make a macOS app out of my Python program?

I've made this question because I had to go through the whole process of creating my own application using Apple's somewhat lacking documentation, and without the use of py2app. I wanted to create the whole application structure so I know exactly what was inside, as well as create an installer for it. The latter of these is still a mystery, so any additional answers with information on making a custom installer would be appreciated. As far as the actual "bundle" structure goes, however, I think I've managed to get the basics down. See the answer below.
Edit: A tutorial has been linked at the end of this answer on using PyInstaller; I don't know how much it helps as I haven't used it yet, but I have yet to figure out how to make a standalone Python application without the use of a tool like this and it may just be what you're looking for if you wish to distribute your application without relying on users knowing how to navigate their Python installations.
A generic application is really just a directory with a .app extension. So, in order to build your application, just make the folder without the extension first. You can rename it later when you're finished putting it all together. Inside this main folder will be a Contents folder, which will hold everything your application needs. Finally, inside Contents, you will place a few things:
Info.plist
MacOS
Resources
Frameworks
Here you can find some information on how to write your Info.plist file. Basically, this is where you detail information about your application.
Inside the MacOS you want to place your main executable. I'm not sure that it matters how you write it; at first, I just had a shell script that called python3 ./../Resources/MyApp.py. I didn't think this was very neat though, so eventually I called the GUI from a Python script which became my executable (I used Tkinter to build my application's GUI, and I wrote several modules which I will get to later). So now, my executable was a Python script with a shebang pointing to the Python framework in my application's Frameworks folder, and this script just created an instance of my custom Tk() subclass and ran the mainloop. Both methods worked, though, so unless someone points out a reason to choose one method over the other, feel free to pick. The one thing that I believe is necessary, is that you name your executable the SAME as your application (before adding the .app). That, I believe, is the only way that MacOS knows to use that file as your application's executable. Here is a source that describes the bundle structure in more detail; it's not a necessary read unless you really want to get into it.
In order to make your executable run smoothly, you want to make sure you know where your Python installation is. If you're like me, the first thing you tried doing on your new Mac was open up Terminal and type in python3. If this is the case, this prompted you to install the Xcode Command Line tools, which include an installation of Python 3.8.2 (most recent on Xcode 12). Then, this Python installation would be located at /usr/bin/python3, although it's actually using the Python framework located at
/Applications/Xcode.app/Developer/Library/Frameworks/Python3.framework/Versions/3.8/bin/python3
I believe, but am NOT CERTAIN, that you could simply make a copy of this framework and add it to your Frameworks folder in order to make the app portable. Make a copy of the Python3.framework folder, and add it to your app's Frameworks folder. A quick side note to be wary of; Xcode comes packaged with a lot of useful tools. In my current progress, the tool I am most hurting for is the Fortran compiler (that I believe comes as a part of GCC), which comes with Xcode. I need this to build SciPy with pip install scipy. I'm sure this is not the only package that would require tools that Xcode provides, but SciPy is a pretty popular package and I am currently facing this limitation. I think by copying the Python framework you still lose some of the symlinks that point to Xcode tools, so any additional input on this would be great.
In any case, locate the Python framework that you use to develop your programs, and copy it into the Frameworks folder.
Finally, the Resources folder. Here, place any modules that you wrote for your Python app. You also want to put your application's icon file here. Just make sure you indicate the name of the icon file, with extension, in the Info.plist file. Also, make sure that your executable knows how to access any modules you place in here. You can achieve this with
import os
os.chdir('./../Resources')
import MyModules
Finally, make sure that any dependencies your application requires are located in the Python framework site-packages. These will be located in Frameworks/Python3.framework/Versions/3.X.Y/lib/python3.x.y/site-packages/. If you call this specific installation of Python from the command line, you can use path/to/application/python3 -m pip install package and it should place the packages in the correct folder.
P.S. As far as building the installer for this application, there are a few more steps needed before your application is readily downloaded. For instance, I believe you need to use the codesign tool in order to approve your application for MacOS Gatekeeper. This requires having a developer license and manipulating certificates, which I'm not familiar with. You can still distribute the app, but anyone who downloads it will have to bypass the security features manually and it will seem a bit sketchy. If you're ready to build the installer (.pkg) file, take a look at the docs for productbuild; I used it and it works, but I don't yet know how to create custom steps and descriptions in the installer.
Additional resources:
A somewhat more detailed guide to the anatomy of a macOS app
A guide I found, but didn't use, on using codesign to get your app past Gatekeeper
A RealPython tutorial I found on using PyInstaller to build Python-based applications for all platforms

Python3/MacOSX integration into pycharm

I have had trouble setting up the pycharm ide on my macosx10.7 with python3..
I have scoured every resource available and tried hundreds of approaches, at this point I must accept my incompetence and seek help via this channel.
In my research, I notice a lack of ground-up explanations on python integration into macosx and how to configure pycharm to import modules, run code within the editor, etc. If i ever solve this I will make a very detailed tutorial.
I have imported python3 successfully, it looks like it is linked appropriately from /sys/lib/frameworks to /usr/lib ...etc -- version control is working just fine.
I think my issue is either in setting environmental variables (tried the program to fix this and tried macports) and in the script needed to execute. it will catch errors throughout but final product does not run in python and returns printout of :
/Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2 /Users/anon/Desktop/pythonpractice/Py_Ex/classes.py
Process finished with exit code 0
i really need to get this configuration sound for my python programming class. please help (I've been through every line of pycharm website) .. preferably is there a way to map it via terminal? thanks for anyone who took the time to read this.
Summary of the discussion above:
Python 3.2.2 installation was broken on this Mac, installing ActiveState Python 3.2.2 from scratch and configuring it in PyCharm has fixed the problem.
Python path to be used in PyCharm settings: /Library/Frameworks/Python.framework/Versions/3.2/bin/python3
Incompatible third-party plug-ins may break PyCharm, uninstall/disable them in Preferences | Plugins.
Ensure the latest PyCharm version is installed.
User's code depends on the graphics.py module which was not in the project or in the PYTHONPATH. Putting it into the project has solved the problem.
Most likely the wrong Run/Debug configuration was used in PyCharm, the easiest way to run or debug such scripts is by using the editor context menu Run and Debug actions. PyCharm creates the configuration automatically and debugging works fine as shown of the screenshot:
If one wants to configure and debug it, he can use the code.zip file to get started.
Sorry for the comments mess above, but it was not possible to move it into chat as user had only 1 reputation point, hence not able to use the chat feature of StackOverflow.

Java SDK Update Tool "Python runtime could not be found"

I'm brand new to java, trying to dive into Java EE and I'm following the instructions here: http://docs.oracle.com/javaee/6/tutorial/doc/gexaj.html#gexaa to try to get everything setup. Unfortunately I'm not able to run the java update tool because I get the error:
Update Tool was unable to start.
The Python runtime could not be found.
To fix this problem use the UC_IMAGE_PATH environment variable to provide a path to a valid image.
To be clear, I've installed Netbeans at the Java EE 6 SDK and that's as much as I know. I have a background in PHP so this is a little different.
What piece am I missing?
check this solution:
http://www.java.net/forum/topic/glassfish/glassfish/update-tool-error
You can also start galssfish server (from NB or .bat file), log into administrator console (web browser: localhost:4848 if You haven't changed default ports) and then run update tool. Works for me, even though the first solution doesn't.
(I know, it's been a year of waiting for the answer, but someone might need this ;) )

Categories