[PYTHON] A story about trying to run JavaScripthon on Windows and giving up.

JavaScripthon is a tool that seems to transpile Python3 code into javascript (ES6) code. Github:https://github.com/azazel75/metapensiero.pj

It also supports SourceMap, and it was said that you can debug with Python code as it is, so I thought it would be interesting and tried it, so I wrote a story that I gave up after all. (I really wanted to make an article "I tried it" ...)

The bottom line is, don't do it on Windows? I don't really know because I don't have a Mac.

Reference below http://www.moongift.jp/2016/05/javascripthon-pythonで書いてes6のコードを生成/

I stumbled upon Installing to Windows.

pip install javascripthon

So, when I did "Ei", I was able to install dukpy, which depends on it. Without vcvarsall.bat. It seems that it was supposed to include Visual Studio Community 2015. http://thinkami.hatenablog.com/entry/2016/06/06/225903

When I put it in and did it again, it fell off. Without unistd.h. I give up because it can't be installed on Windows with pip install like a unix type.

I ran from Python and stumbled.

I decided to clone it from Github and run it directly. Since dukpy seems to be an engine for running js, I thought that it would not be necessary if only transpile was used, so I decided to run it directly.

If you read the code, it's probably necessary, so comment out the import of dukpy in src / metapensiero / pj / api.py and execute it.

python -m metapensiero.pj source.py

When I said "Ei", it fell. UnicodeDecodeError. This is the cause of the fall.

src/metapensiero/pj/api.py


src_text = open(src_filename).readlines()

I will die from Japanese comments. I will rewrite it once.

src_text = open(src_filename, encoding='utf-8').readlines()

It fell again. This is the next cause.

src/metapensiero/pj/processor/util.py


def parent_of(path):
    return '/'.join(path.rstrip('/').split('/')[:-1])

Windows backslash delimiters aren't taken into account. For the time being, I want to run it on Windows, so I will change it to backslash once.

def parent_of(path):
    return '\\'.join(path.rstrip('\\').split('\\')[:-1])

I feel like it worked. .. ..

python -m metapensiero.pj source.py

Now I have a .js file and a .js.map file. Hooray.

However, it seems that Python that goes a little deeper cannot be transpiled. For example

for i, x in enumerate(list1):
    #processing

Or, a loop with two variables seems to be useless and will result in an error.

Let's give up already. Let's buy a Mac first. Let's talk to my wife.

Recommended Posts

A story about trying to run JavaScripthon on Windows and giving up.
A story about trying to connect to MySQL using Heroku and giving up
A story about trying to install uwsgi on an EC2 instance and failing
A story about trying to run multiple python versions (Mac edition)
A story about trying to use cron on a Raspberry Pi and getting stuck in space
A story about a beginner trying hard to set up CentOS 8 (procedure memo)
How to run Django on IIS on a Windows server
A story about a Linux beginner putting Linux on a Windows tablet
A story about trying to implement a private variable in Python.
Python 3.6 on Windows ... and to Xamarin.
How to set up WSL2 on Windows 10 and create a study environment for Linux commands
A story about trying to automate a chot when cooking for yourself
A story about wanting to think about garbled characters on GAE / P
Run py.test on Windows Anaconda and MinGW
A story about Python pop and append
A story about a 503 error on Heroku open
Run matplotlib on a Windows Docker container
A story I was addicted to trying to install LightFM on Amazon Linux
[Memorandum] A story about trying OpenCV tutorial (face recognition) in a Windows environment
A story of a deep learning beginner trying to classify guitars on CNN
Build Linux on a Windows environment. Steps to install Laradock and migrate
Install and run Python3.5 + NumPy + SciPy on Windows 10
Put MicroPython on Windows to run ESP32 on Python
A story about building an IDE environment with WinPython on an old Windows OS.
A story about Go's global variables and scope
A story about displaying article-linked ads on Jubatus
A story about running Python on PHP on Heroku
How to live a decent life on 2017 Windows
How to run a Django application on a Docker container (development and production environment)
A story about modifying Python and adding functions
A story that got stuck when trying to upgrade the Python version on GCE
A story about how Windows 10 users created an environment to use OpenCV3 with Python 3.5
A story of trial and error trying to create a dynamic user group in Slack
A story about a Python beginner trying to get Google search results using the API
Until you create a machine learning environment with Python on Windows 7 and run it
A story about trying to introduce Linter in the middle of a Python (Flask) project
A story of trying out pyenv, virtualenv and virtualenvwrapper
A story about trying a (Golang +) Python monorepo with Bazel
A story about kindergartens, nursery schools, and children's gardens
A story about struggling to loop 3 million ID data
I'm a windows user but want to run tensorflow
Create a decent shell and python environment on Windows
Good and bad code to compare on a minimap
Error and solution when trying to run a classifier made with Labellio with my own ubuntu
[Note] A story about trying to override a class method with two underscores in Python 3 series.
[Django] A story about getting stuck in a swamp trying to validate a zip with form [TDD]
A story about porting the code of "Try and understand how Linux works" to Rust
How to run a trained transformer model locally on CloudTPU
How to run a Python file at a Windows 10 command prompt
A story about how to specify a relative path in python.
How to mount a Windows 10 directory on Ubuntu-Server 20.04 on VMware Workstation 15
Try to bring up a subwindow with PyQt5 and Python
A story about how to deal with the CORS problem
A story about a GCP beginner building a Minecraft server on GCE
Building a Python development environment on Windows -From installing Anaconda to linking Atom and Jupyter Notebook-
The story of making a tool that runs on Mac and Windows at the game development site
A story about everything from data collection to AI development and Web application release in Python (3. AI development)
[Google Photo & Slack Photo Bot] A story about making a bot that acquires photos in Google Photos and sends them to Slack.
About the error I encountered when trying to use Adafruit_DHT from Python on a Raspberry Pi
Run Jupyter on Ubuntu on Windows
Run Openpose on Python (Windows)