Python for Android [closed] - python

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I had a look at Kivy,but the problem is it needs a virtual machine to run apps. Isn't there a way where python codes are directly converted to java bytecode which can be run by android without any virtual machine? What are the merits/demerits in terms of performance?
May be something in jython which would help?

Try SL4A for running Python code directly on your device. It requires no compiling, conversion to bytecode or virtual machines.
More information Here
Also, you can download an IDE (I've used Eclipse, like in the tutorial you will find on the site), installed a plug-in, created my source files there and then uploaded them to my phone, if you're uncomfortable with writing code on your device.

This page has full instructions on how to package a Kivy app into an APK: http://kivy.org/docs/guide/packaging-android.html

I think some one mislead you a lot or you are confused about how things work with kivy.
I'll take this opportunity to try and make things a bit more clear.
Kivy can be used to build stand alone apk, only if you had searched kivy in google play. This link shows a list of apps that mention kivy, there are a lot more apps there that use kivy and just don't mention that. There is also a partial user maintained list you can look at. You can install the apps from google play and you'd see that they are self contained and don't require you to download anything extra.
There are very easy instructions available on how to build a apk in the link mentioned by #Marcins.
Every python code passes through the python interpreter usually pre-compiled to pyc, that's how python works even Java uses a virtual machine JVM, Android's implementation uses Dalvik VM. You can learn more about the VirtualMachines used in the languages like java/python here. The python interpreter/vm consumes the code and executes it natively, it doesn't convert it to java byte code.
if you need to make something that needs more performance then you can even use cython with kivy to get more speed.

Related

A Real Talk About Python Software Distribution [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I know this is a hot topic and many people ask this question but I have the feeling I am missing something. What is the proper way to make a python application for end-users? Like, old-school offline .exe and so on. Many users won't touch the terminal/shell and to be honest most software these days is incredibly easy to install. What I know so far:
There are packages out there that can make your software ready for redistribution like
pyinstaller, cx_freeze, py2exe
I wrote my fairly complex software in like 2 weeks and going crazy for days over making pyinstaller work with my external packages. Is this pain normal? Have I made a mistake by relying on an interpreted language? Because compiling this stuff is mean business. In many other languages you just build the stuff within the IDE and there you go, built.
I am not concerned that my code might be decompiled, so what I have tried is to just create a .bat file with commands to execute my script with my virtual environment(!) python. Can I just manage to have the Python venv in place with my scripts without the user having to install it himself?
Or what is the "usual" way to do this? Use Cython? Or pyinstaller? Praying to the lord of code?
FYI: I am using Python 3.6.8, Windows 8 (don't you dare making fun of me :D) and Pycharm 2019.2
However thank you in advance for your time, regards,
Arjaan
There is no correct or established way of how to create an executable file for your Python project. It's opinion-based.
And how you want to distribute your software is entirely up to you. It can be source code, compiled, as a docker image, through Heroku One-Click deployment, debian package, all of the above, ???.
Having choices is nice. Some people need a really simple solution then Heroku or an exe file is nice. Some people are Docker power users, then a multi-arch docker image is nice. Some people want to modify the source code than having the source code is nice. Some people like debian packages and want your project with a systemd service file automatically enabled and started.
You might also not put into the work of getting docker/debian/heroku to work and just tell them a step by step guide on how to get it to run.
Debian and Heroku route might require some periodic maintenance due to the Linux distros updating to newer versions.
There is so much to it and it is an endless discussion where noone is right or wrong.

How can I pack python into my project? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am making a program that will call python. I would like to add python in my project so users don't have to download python in order to use it, also it will be better to use the python that my program has so users don't have to download any dependency.
My program it's going to be writing in C++ (but can be any language) and I guess I have to call the python that is in the same path of my project?
Let's say that the system where the user is running already has python and he/she calls 'pip' i want the program to call pip provided by the python give it by my program and install it in the program directory instead of the system's python?
It's that possible? If it is how can I do it?
Real examples:
There are programs that offer a terminal where you can execute python to do things in the program like:
Maya by Autodesk
Nuke by The foundry
Houdini by Side Effects
Note: It has to be Cross-platform solution
There are programs that "freeze" your python program including Python itself, for example Pyinstaller (http://www.pyinstaller.org/)
It won't help with the requirement in the third paragraph though, for that you'd have to include Python itself as part of the complete download, which seems unnecessary.
In order to run python code, the runtime is sufficient. Under Windows, you can use py2exe to pack your program code together with the python runtime and all recessary dependencies. But pip cannot be used and it makes no sense, as you don't want to develop, but only use the python part.
To distribute the complete python installation, like Panda3D does, you'll have to include it in the chosen installer software.
You can use py2exe to turn you python program into an executable. You do not need to keep python in the executable.

How to put code into html for others to play in browser [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I recently made a game that I enjoy playing, and so do my friends. After they download python for themselves, receive the .py files and then start playing. It's a hastle. I was wondering if there was anyway for me to take my game and all in it, put it in some .html that I host online, and have anyone play it whenever they want.
No, it's not possible to play a python game on a web page. Python is interpreted locally, on the user's computer. They have to download the files in order to play.
However, you can use a utility like py2exe to make your game into an executable file, so it can run on its own without the user having to install python. (I'm assuming this is for Windows -- Macs already have Python installed).
update: Per Anderson Green's comment, putting Skulpt on your site will allow visitors to use python scripts in a web page.
Depending on your version of python you could look at packing it into an executable that would be easier to distribute. But unless there's some way of having your website be a persist ant virtual python environment, I don't think web hosting will be the way to go.
For python 2.x I know distutils is one method of packing an executable, but the last I checked, it wasn't compatible with 3.x.

Graphical Front-end for Python script [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I wrote a python script here Github
It is just something I wrote to practice. The script asks for a input directory and output directory and the method of compression and then compress the files from input directory and stores the compressed archive to the output directory.
I want to make a graphical frontend for this script. I am using Ubuntu 10.10 (GNOME).
Is it possible to do so?
If yes, then where should I start?
I want to do this just for learning purposes.
Thanks
It's certainly possible. There are a ton of GUI frameworks available so you'll have more then enough choices. Given your OS is Ubuntu I would look into PyGTK first. I personally found PyGTK fit my brain pretty well and I really liked the documentation. The fact that it's the native toolkit for your Window Manager is a nice plus in that your app will hopefully look like the other Gnome apps you're already running.
Of course you could use Tkinter which is bundled with Python and cross platform. Or you could look into using PyQT or wxPython.
To be a little crazy, since this is a learning exercise, you might want to use something lower level so you might look into something like Pyglet or Pygame and spend some time learning how to build your UI widgets.
If you're looking for touch interface or iOS / Android support then checkout Kivy
Good luck.
Kivy also looks like a good alternative.
Kivy - Open source Python library for rapid development of applications
that make use of innovative user interfaces, such as multi-touch apps.
I found PyQt pretty easy to get up and running with. Check out the wiki docs here.
I find MVC a very good design pattern to use in this case, so, you might try to salvage your code (it seems very simple).
For a GUI framework, I suggest Mike Steder's response, and this list and a large list found here.

Android Python Programming [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Can I program for Android using Python? I seem to have stumbled upon many links while searching... however neither of them is concrete.
Any suggestions? I want to write apps for Android but really don't want to get into Java for all this.
PS: My question is whether I can write proper, full fledged apps for Android.
Checkout Kivy. They have done a really great job so far, and I am a big fan of their work. It is still lacking some providers, but they keep adding new stuff to it everyday. First thing you need to do is to check your requirement against what they can offer based on their documentation. They have create an amazing framework for input such as multi-touch or pen handling. They use OpenGL ES internally, as a result complex graphics and visualizations can run very fast when interacting with the the application. Their process for creating an apk is also very straight forward.
Check the new Python for Android project.
Edit: This is not Kivy, this is a seperate project, intended to be a toolchain usable for other toolkit. The architecture is modular, and you can include new recipe for including new python extensions (as brew, macports, cygwin etc.).
Edit: This is not Py4A, but python-for-android.
This is great for starters:
Embed Python 2.7 interpreter and your scripts into an Android APK
No, not currently. ASE (Android Scripting Environment) allows you to do simple script apps, but you can only write proper Android apps in Java.
Yep, you can.
Check ASE
Edit:
Ok, after comments:
I haven't read the question properly. No you can't write write proper, full fledged apps for Android, but anyway check ASE. It is really cool project.

Categories

Resources