Pythonista 3.4 is out now (supporting Python 3.10)

I thought the development discontinued…, but I was wrong!

Running on iPad. Output of Stash version command. See Python is 3.10.4.

Python is now 3.10.4. Python 2 is no longer included.

After 3 years of silence, the great Python IDE for iOS/iPadOS, Pythonista 3 is finally released. You can now execute your Python 3.10 codes.

Pythonista 3 ← Link to the App Store

For details (not very much, tough), visit the official website below:

https://omz-software.com/pythonista/docs-3.4/py3/ios/new.html

Since Python 2.7 is no longer included, you cannot run codes written in Python 2.x directly. E.g. SSH command in StaSh does not run unless you make a few changes (I’ll post another article how you can make the ssh command work).

StaSh, a bash-like shell environment for Pythonista is not fully compatible yet. Installer works, and pip command is able to install packages, but somehow entries in the .stashrc file is not fully loaded – only the fist line becomes available.

StaSh installation

It is recommended to cleaninstall Pythonista 3 to install StaSh. Even in the last few days the installation process changed, so I recommend to visit the official Github constantly. For me the dev version works better (mainly ‘ls -l’). You can copy the command below and execute in Console to install the dev version.

url = 'https://raw.githubusercontent.com/ywangd/stash/dev/getstash.py'; import requests as r; exec(r.get(url).text.replace('master', 'dev'))

As advised, exit and relaunch Pythonista 3, and run launch_stash.py located in “This iPhone” to execute the StaSh shell.

Let’s install Django 4.0 (latest 4.2.1 won’t work.)

As far as I testd, Django version 4.0 can build the test page. Latest version 4.2.1 will be installed if you do not specify the version number, however it won’t run with an error regarding openssl_md5 when you launch django-admin. Copy and execute the below in StaSh.

pip install django==4.0

In my case, StaSh installation logs and pip show Django reads version 4.2.1 but in Console, import django then print(django.__version__) shows “4.0” correctly.

Anyways, after a successful installation of Django, restart Pythonista 3, launch StaSh and execute the below:

django-admin startproject mysite

You can now add an argument below to manage.py in the editor window (press and hold ▷ button then add the arg) and run.

runserver --noreload

If you see an error message “CommandError: You must set settings. ALLOWED_HOSTS if DEBUG is False“, simply ignore for now and restart Pythonista 3 then run manage.py again. Also, allow network access if asked by iOS.

If all goes well you see the URL http://127.0.0.1:8000/ . Either tap to open in Pythonista built-in browser or copy-paste in a web browser to open the page. Congrats! A rocket GIF image means your Django site is working! I have a few Django in StaSh/Pythonista articles in my website for little more detailed instructions.

I never expected an update so I’m happy.

Recently I was playing anotehr iOS app, a-Shell which is a Unix/Linux-like shell environment where you can write and run Python 3.11 codes. I like it as it’s more like a standard CLI shell with multiple programming languages, you can edit code in vim editor, etc. One thing I was disappointed about is the behavior of Django and Flask web apps — you need to open web browser and a-Shell back and forth to process the code. Pythonista 3 is a great IDE and StaSh is a nice tiny shell to play with. I expect StaSh will catch up soon. I’m back to Pythonista 3 and will post more articles.

Image by Stable Diffusion

This is totally off topic — I start adding details of Mochi Diffusion generated image when I add one as an eye-catching image. This one was generated with only 20 steps so looks bit scary, kinda typical AI generated image, but when I increased to the max 50 steps of Mochi Diffusion, people didn’t that look happy. Decided to go with more passionated image. And it should be more suitable than a free-of-use beautiful photograph of nature which isn’t related to the article at all.

Date:
2023年5月6日 14:35:09

Model:
realisticVision-v20_split-einsum

Size:
512 x 512

Include in Image:
cartoon, people happy with a new release of software

Exclude from Image:


Seed:
3343127351

Steps:
20

Guidance Scale:
11.0

Scheduler:
DPM-Solver++

ML Compute Unit:
CPU & Neural Engine

Install and Setup Django in Pythonista3 (iOS app)

How to Set up Django in Pythonista3, iOS app for iPhone and iPad:

First, make sure you have StaSH installed in your Pythonista3 app.

In StaSH execute following command:

pip install Django==1.11.6

Select version “1.11.6” or Long Term Support version available. See Djangoproject.com website for the latest LTS version available. (Comment added on Jun 12, 2021) you may be able to execute “pip install django” and the version 3.2.4 will be installed. Specifya version only when necessary.

Quit and launch Pythonista <– This is one of most important steps when you make changes to Pythonista3!

Create an application (in stash)

django-admin.py startproject mysite

Quit and launch Pythonista

Open /mysite/manage.py
Go to console and run:

import sys
sys.path

Locate and copy a line like below where “…” is device specific.

/private/var/mobile/.../Documents/mysite

Go back to the edit page (manage.py).
Add a line like below under “import sys” — replace “PASTE HERE” with the line copied in the prev step. (Comment added on Jun 12, 2021) Removed unnecessary “=” after “append”.

sys.path.append(“PASTE HERE”)

So, it will look something like below:

sys.path.append("/private/var/mobile/Containers/Shared/AppGroup/C1F57ABC-DDDD-EEEE-FFFF-B0B0E0B0B0E7/Pythonista3/Documents/mysite/")

Quit and launch Pythonista

Open /mysite/manage.py, tap and hold the play (run) button and enter “runserver --noreload” as an argument. You may need to copy and paste “--noreload” without double-quotes.


If you see unforseen errors, quit Pythonista and relaunch then follow the steps again.
If successful, you see something like below in the Console:

Performing system checks...

System check identified no issues (0 silenced).

You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
November 03, 2017 - 20:46:35
Django version 1.11.6, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Now, open http://127.0.0.1:8000/ in Safari or any other web browser.

Version 3.2.4

If you see the “Congratulations!” page, your setup is complete, and it’s time to move forward to programing your own site/app.
Make sure you quit and relaunch Pythonista to properly apply your changes to your Django sites/apps.

StaSH log (installation of Django 1.11.6):

[~/Documents]$ pip list
[~/Documents]$
[~/Documents]$
[~/Documents]$ pip install django
Querying PyPI ...
Error: Source distribution not available for Django: 2.0b1
[~/Documents]$ pip install Django==1.11.6
Querying PyPI ...
Downloading package ...
Opening: https://pypi.python.org/packages/13/26/f3841e00663027ba7cf7ce7ba2cabb682a83cf0629bef013d70bebefa69d/Django-1.11.6.tar.gz
Save as: /private/var/mobile/Containers/Data/Application/20C8FA54-EEEE-FFFF-8888-3BACC5555555/tmp//Django-1.11.6.tar.gz (7874450 bytes)
7874450 [100.00%]
Extracting archive file ...
Archive extracted.
Running setup file ...
Handling commandline script: django/bin/django-admin.py
Package installed: Django
Dependency available in Pythonista bundle : pytz
[~/Documents]$
[~/Documents]$
[~/Documents]$ which django
[~/Documents]$ pip list
Django (2.0b1) - A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
[~/Documents]$
© Peddals.com