r/pythontips • u/Hatoris • May 29 '19
Python and git on your Android device
Everybody told you that " to improve your python skill you need to practice" but you do not always have your laptop with you. Hold on, here is something that can be done.
The purpose of this small tutorial is to give you the ability to install and run python and git on your Android device.
Disclaimer : I have no affiliation with any applications I will present.
Introduction
First thing first, you do not need to root your phone in order to follow this tuto. All application are free, of cource. Applications we will use are :
pydroid 3 a pretty good application. It's free, prenium version give you access to autocompletion and some intelisense, it's not the same level as pycharm but is pretty usefull.
Termux your Linux shell on your mobile, with this you will have access to git.
git, the most famous version control system for all your project
Installation
From the play store install :
From Termux
Ok, now you have it, open Termux and run the following command.
apt-get update
apt-get upgradeThen we can install git.
apt-get install gitSetup
It's time to be organize and hack a little bit pydroid3.
First create a folder where all your application will site. Mine is called programming and I add it under /storage/emulated/0. This path is the same as your document and download folders.
When it's done, copy the path in your clipboard and open pydroid3. On the right, click on folder icon and then open. Follow this path Home, accomp_files, iiec_run and finally open iiec_run.py. (Home/accomp_files/iiec_run/iiec_run.py)
Now, right under import sys add the following.
PATH ="/storage/emulated/0/programming/" #the path of your programming folder
# A tuple with all your package folders in it, at start you will have nothing, but with time it may look like mine
APPs = (
"kbase",
"RemoveMedia",
"pyAnalysis",
"BioPlate",
"appPharma",
"pytexu",
"Tools",
"Dilution",
"BioPlateWeb",
"pythontex-command")
# Finally we append all path to system
for app in APPs:
sys.path.append(PATH + app)This little hack will alow you to import your package, those you created, not those that you will install using built in pip.
Your first start
Take your favorite web hosting service, create a package in it. Copy the link to clone it. Then go on your device and open Termux. run the command cd /emulated/storage/0/programming/, your are now in your programming folder. Clone your repo with the following git clone https://web-hosting.com/myRepo (replace the link with the one you copied). When it's done, open your pydroid3 app, and open your cloned repo. Don't forget to add your package in the iiec_run.py.
Happy coding
Fun fact
I written 90 % of my package BioPlate using this setup. When you have, like me, more than one hour and half of common transportation a setup like this is really cool.
4
u/heo5981 May 29 '19
I use Termux as well to test and make small changes to my current Django + React web app project when I'm far from my laptop (at work, for instance). The only drawback that I've seen is that if I put my project in storage/shared to access the files with an editor like DroidEdit, yarn fails to launch the development server. So I just put everything inside Termux data folder and access the files using nano instead. For Python, everything works normally, thought.
1
May 29 '19
I wish I was as good as that. What books do you reccomend if your teaching yourself python? Or maybe even youtube videos?
2
u/heo5981 May 31 '19
Don't know if it sounds cliche or not but if there's one thing I learned about programming is that you'll learn much more if you work on a project of your own. For instance, when I started with this web app, I knew nothing about Redux and I wasted a lot of time because I was trying to do things without knowing what to do. After working for at least two months with this web app, I can tell you that I got pretty good with Redux, not gonna say that I'm an expert but at least I know the basics of using it, on my next project, I'll waste way less time, at least on implement Redux.
It also depends on your goals, why are you learning programming? To make AAA games? Develop native apps, websites? Just to make your life easier? I ask that because each area will have you need something specific but all of them will require the basics. So master the basics like variables, data structures, conditionals, functions, error handling, some OOP and get to work on a project that's useful to you. Maybe a website with Django, or a GUI program with Tkinter or just a bunch of scripts that make your life easier at some task.
I started my journey around 4 years ago with Codecademy, went trough their Python course at the time and it was awesome for me. But it looks like they are not so loved by the community as I thought they were, also with the recent monetization of the platform it seems to have lost quality. A Python book that gets mentioned a lot is Automate the Boring Stuff, free on the web. Maybe watch CS50 lectures on YouTube as well? They'll give you a solid understanding of computer science as a whole, at least the basics.
If you need help with anything specific to Python or Javascript, I'd love to help, just drop me a message!
1
May 31 '19
I have automate the boring stuff I haven't cracked it open yet, as far as why I want to learn to code is cause I'm getting a degree in industrial technology but also a degree in computer information technology, I'm also into cyber security, but I want to learn how to control machinery with computer code, how to control how a machine behaves and I had some things I wanted to design to make machinery more safe for operators and I think computers can help, I get my degree in industrial technology next year than I will start my CIT degree, so I have way more knowledge of like hydraulics and belts and gears and bearings and industrial equipment and tools and motors than like you know, computers, although I have dabbled in linux adminsitration and hacking cause its cool but I never truly get expert at it, I understand CIT fundamentals basically but I want to learn to code so bad :/ plus since more automation is happening in factories and industrial enviroments (which is where I work a lot of ppl hate factories and shit but I love them cause I just think machinery is beautiful) more machines are being controlled by computer systems and as a maintenance mechanic which is my career choice (repairing machinery) I think knowledge of computers will be very good skills to have. That way you dont only repair the physical aspects of the machinery like valves, pumps, etc. But you can know how a computerized machine thinks and troubleshoot software and hardware as well plus with robotics moving in, I mean c'mon man.
1
May 30 '19
The class I'm taking in school (late 30's, online school) basically just gives me an assignment each week. No guidance. Give it a shot, my first assignment was to make a program to convert Fahrenheit to Celsius (or back). Just figure out how to do that.
Message me after you are done and I'll tell you the second assignment.
I'll give you a hint, as far as I can tell, even the simplest execution of each assignment will teach you a lot.
1
May 30 '19
Uhhhh, I'm at work lol. But this sounds like a cool idea. Can I PM you?
1
2
u/mikkowus Feb 14 '22 edited May 09 '24
tie rinse safe modern roll alive ossified marvelous whistle decide
This post was mass deleted and anonymized with Redact
6
u/Gee10 May 29 '19
Not to hijack this thread, but is there any similar guidance people are aware of for iPhone?