Think about how to program Python on the iPad

Preface

This is Qiita's first post. I would like to post in "To look back on my own" and "To help people with similar problems". I'm unfamiliar and this post is full of letters. I will gradually get used to using it, so thank you m (_ _) m

Introduction

In my work, I use Matlab to do Deep Leaning etc., but tensorflow has a higher degree of freedom and I can use the latest model ... So I tried to build an environment where I can easily study Python, more specifically tensorflow. I thought about it and tried various things. The reason why the title is written on the iPad is just because I want to create an environment where I can freely code and execute at home, or on the go.

Aimed environment

The target environment is ** to be able to code and execute programs of Python3 system using iPad Pro 11inch (2018) *. Also, since I want to do deep learning, it is also a necessary condition that ** a specific Python library ( 1) can be used **.

We also aim to create an environment where you can do it for free. At least I want to avoid subscriptions, so I'm not currently considering various cloud services (Azure, AWS, etc.).

(* 1) I want to use the following Python library at a minimum. ・ Numpy ・ Matplotlib ・ Tensorflow ・ Pillow (I want to use Open CV, but Pillow alone may be enough)

In this post, we will even investigate candidates for the Python environment. </ font>

Conclusion

In the next chapter, I will write it as sloppy, so I will state the conclusion first. </ font> If you want to code and execute Python (tensorflow) using iPad, I found that the following environment seems to be good.

  • "code-server" or "Eclipse Theia"
  • "Gitpod"
  • "Jupyter Lab"

However, except for ** Gitpod, it is necessary to prepare a separate PC other than the iPad. ** </ font> As I looked it up, I couldn't find a way to study tensorflow on the iPad alone, and both methods would run Python on Linux or Windows OS. It will be quite difficult to run Python itself and various libraries on iOS and iPad OS.

I have a PC and an iPad, but both machines need to be started and the restrictions may be quite large. It was more troublesome than I thought I would look it up.

For the time being, if you want to complete with the iPad alone, Gitpod is influential.

Candidate environment

I took a quick look at the Python environment that could be used. In this chapter, we will describe each environment as if it were a memo, but it is recommended to skip it because it is written as sloppy. </ font>

Buy Pythonista 3

There is an iPad application called Pythonista3 [^ 1] that can execute Python on the iPad's local environment. The ¥ 1,220 app suddenly deviates from the initial goal of "free ...", but it's a sold-out app and the evaluation is quite high, so isn't it bad? I thought.

** But ... ** </ font>

It seems that there are restrictions on the libraries that can be used, and it seems to be useless because tensorflow cannot be used. In the first place, it is not realistic to do deep learning on the iPad's local environment.

However, as mentioned earlier, it seems to be a great app because it seems that you can easily create a GUI app with a highly rated app. I won't cover it anymore in this post, but if you are interested, please check it out. Pythonista3

  • The above image is taken from the official website of Pythonista3 [^ 4].

[^ 1]: URL of the App Store of Pythonista3: https://apps.apple.com/jp/app/pythonista-3/id1085978097 [^ 4]: Pythonista3 official website: http://omz-software.com/pythonista/

Set up a browser-powered IDE server on Linux ("code-server" or "Eclipse Theia")

This seems to be the favorite method. It seems that there is a VS Code-like IDE that can be accessed remotely from a browser by setting up a server on a Linux environment. I think that it is a favorite because it can be used from the iPad browser, it does not depend on the local (iPad) machine power, it seems that you can work with a high degree of freedom in the Linux environment, it is free, and you can use extensions like VS Code. I will.

There are two similar IDEs, ** code-server ** [^ 2] and ** Eclipse Theia ** [^ 3]. Since they are very similar, we do not know "how they are different" or "which is better" at this time. (Because there was not much information in Japanese).

code-server

  • The above image is taken from the Github repository [^ 2] of code-server. A screen similar to VS code can be handled on the browser.

[^ 2]: code-server Github repository: https://github.com/cdr/code-server [^ 3]: Eclipse Theia's Github repository: https://github.com/eclipse-theia/theia

Use GitPod

It seems to be a cloud IDE service using Eclipse Theia mentioned above. I said that I should avoid cloud subscriptions, but I'm off the target again. Excuse me, it's limited, but it's free to use, and it seems to be very easy to use, so I decided to make it a candidate.

This can be used if you have a Github account, and it seems that you can change, debug and commit the code on Github.

[How to use] I think the URL of the Github repository is as follows.

https://github.com/[account name]/[Repository name]

↑これを↓以下のように,"gitpod.io/"とつけるだけでgitpodのIDE画面に遷移します.(初回はGitpod利用のためのアカウント紐付けが必要)

https://gitpod.io/github.com/[account name]/[Repository name]

It is a good candidate because it is easy to access. However, a charge is required for long-term use. It seems to be the best to try it lightly, but please note that you will have to pay for it if you want to do it freely. I feel that it is best when I modify the source code of Github a little and debug → commit. As shown in the image below, this is also an image like VS code that can be used in a browser.

Gitpod

  • The above image is quoted from Gitpod official website [^ 5]

[^ 5]: Gitpod official website URL: https://www.gitpod.io/

Create a Jupyter server on Windows (also possible on Linux)

You can set up a Jupyter server on a Windows or Linux server and access it from the iPad browser. This is not a powerful IDE like Gitpod, code-server, Eclipse Theia, but it seems to be a recommended method for those who just want to be able to run it in Notebook format (.ipynb). In fact, for deep learning, the notebook format is probably the most powerful because it makes it easier to see the data.

Apparently, recently, Jupyter Lab is being actively developed instead of Jupyter Notebook [^ 6], so Jupyter Lab is good. You can code and execute Python by accessing it from a browser as shown in the image below (which is also a bit like VS Code). However, note that you will be dealing with the Notebook format of .ipynb files instead of the general .py files. (You can also run .py files, but I think it's a bit tricky to use)

Jupyter Lab

  • The above image is quoted from Jupyter Lab official website [^ 7]

[^ 6]: There is a person who explains Jupyter Lab well. It's no good, so please take a look. https://qiita.com/kirikei/items/a1639954ce5ccaf7ac3c

[^ 7]: Jupyter Lab official website URL: https://jupyterlab.readthedocs.io/en/stable/index.html

Finally

I wrote it for a long time, but I felt that studying tensorflow on the iPad was a relatively high threshold. It seems easier to do it obediently on a PC (or on a laptop with moderate specifications).

However, I realized that if I could manage to build an environment, I would be able to study machine learning on the iPad while rumbling.

Supplement

I forgot to write about the most promising candidate ** "Google Colab" **! !! !! </ font> Since it is a free cloud service (with restrictions), it probably does not require environment construction and is the most promising candidate, but we have not been able to investigate it thoroughly. Therefore, it will not be dealt with in this post. I'm sorry, but please forgive me. (If you can afford it, we will investigate and add it.)

Recommended Posts