nx-python: Create Python Homebrew for the Switch!

HlzR.jpeg

nx-python
is an ecosystem for developing and running Python homebrew applications on the Nintendo Switch. PyNX serves as the entry point to this ecosystem and allows you to run Python apps on your Switch. It is a homebrew app that contains a port of the CPython interpreter and allows you to run Python applications from the Homebrew Menu. Just name your application main.py and place it next to the PyNX.nro, and it will be executed as soon as you launch PyNX from the Homebrew Menu. Simply grab a release build and copy the content of the ZIP archive into the /switch folder on your SD card. PyNX will appear on the Homebrew Menu. Currently, Python 3.5 is supported. Basic things should work fine, but for many advanced things, like PyGame, you will have to wait a bit until they are supported. This also includes threading, as well as the signal module. Those are high priority, though, so you won't have to wait for them for too long, hopefully. For Switch-specific things, such as controller input or filesystem read/write, you can use the nx package that's included in PyNX (see documentation).

I hope nx-python will allow many more people to develop awesome homebrew applications for the Switch. :)

If you encounter a problem, make sure to join our Discord and tell us about it, or, alternatively, reply to this thread.

Quick links: Download | Documentation | Discord | Source

Special thanks to DavidBuchanan314, @MarcusD, @Stary2001, rami, and several other people from ReSwitched as well as the SwitchBrew team, the devkitPro team, and the Python Software Foundation.
 
Last edited by AileenLumina,

Cyan

GBATemp's lurking knight
Former Staff
Joined
Oct 27, 2002
Messages
23,749
Trophies
4
Age
45
Location
Engine room, learning
XP
15,648
Country
France
I didn't try RCM mode yet on my console, but thank you for your reply.
I'm sure someone else will be able to test.

Hey, I see you found the newly added bbcode :P
 

AileenLumina

Python main, software engineer and API designer
OP
Member
Joined
Sep 27, 2015
Messages
631
Trophies
0
Age
26
XP
614
Country
Germany
Yeah, though I feel they could need some visual adjustments, they look slightly out of place as they don't fit into the site's overall appearance too well (and their bottom margin is quite a bit larger than the top margin). It's not very polished yet, but I like the addition. :)
 

Nudu

Well-Known Member
Newcomer
Joined
Feb 18, 2018
Messages
75
Trophies
0
Location
Osaka
XP
391
Country
Germany

nx-python
is an ecosystem for developing and running Python homebrew applications on the Nintendo Switch. PyNX serves as the entry point to this ecosystem and allows you to run Python apps on your Switch. It is a homebrew app that contains a port of the CPython interpreter and allows you to run Python applications from the Homebrew Menu. Just name your application main.py and place it next to the PyNX.nro, and it will be executed as soon as you launch PyNX from the Homebrew Menu. Simply grab a release build and copy the content of the ZIP archive into the /switch folder on your SD card. PyNX will appear on the Homebrew Menu. Currently, Python 3.5 is supported. Basic things should work fine, but for many advanced things, like PyGame, you will have to wait a bit until they are supported. This also includes threading, as well as the signal module. Those are high priority, though, so you won't have to wait for them for too long, hopefully. For Switch-specific things, such as button input or filesystem read/write, you can use the nx package that's included in PyNX (see documentation).

I hope nx-python will allow many more people to develop awesome homebrew applications for the Switch. :)

If you encounter a problem, make sure to join our Discord and tell us about it, or, alternatively, reply to this thread.

Quick links: Download | Documentation | Discord | Source

Special thanks to DavidBuchanan314, @MarcusD, @Stary2001, rami, and several other people from ReSwitched as well as the SwitchBrew team, the devkitPro team, and the Python Software Foundation.
Wow I just started to learn Python... print:"Awesome"
 

AileenLumina

Python main, software engineer and API designer
OP
Member
Joined
Sep 27, 2015
Messages
631
Trophies
0
Age
26
XP
614
Country
Germany
Roadmap

v0.5.0-alpha
- New PyNX menu, lets you select which Python program to run on launch
- Miscellaneous fixes to controller input

v0.5.1-alpha
- Fix `nx.filesystem.Savedata.backup`
- Polish the PyNX menu (highlight Python programs using color codes etc.)

v0.6.0-alpha
- libnx gfx bindings
- ImGui (and possibly SDL2) support
- full joystick support
- other HID stuff
 
Last edited by AileenLumina,

linga

Active Member
Newcomer
Joined
Apr 7, 2018
Messages
33
Trophies
0
XP
157
Country
China
I get an error:

Args:
sdmc:/switch/pyNX/pyNX.nro
Fatal python error: py_Initialize:can't initialize time
Oserror:[Errno 22]invalid argument

current thread 0x0000000000000000 <most recent call first>:
 
Last edited by linga,

takopov

New Member
Newbie
Joined
Nov 5, 2016
Messages
3
Trophies
0
Age
29
XP
255
Country
United States
I'm really excited for the gui implementation. I've spent the past couole months learning python and lately my project has been a webbrowser using pyqt. Will it be possible to import that on my own using this? Sorry if this has been answered already
 

freshrust

Member
Newcomer
Joined
Jul 23, 2018
Messages
6
Trophies
0
Age
34
XP
62
Country
Thailand
I'm really excited for the gui implementation. I've spent the past couole months learning python and lately my project has been a webbrowser using pyqt. Will it be possible to import that on my own using this? Sorry if this has been answered already

Also thought of this...I mean it is quite infuriating that Nintendo leaves this basic of feature out.

Coming from a noob, would NX-python theoretically run something like a web browser written in python? Attached is something I pulled from user TrebuhD on GitHub. (Cannot post links yet)
 

Attachments

  • webBrowser-master.zip
    1.7 KB · Views: 273

AileenLumina

Python main, software engineer and API designer
OP
Member
Joined
Sep 27, 2015
Messages
631
Trophies
0
Age
26
XP
614
Country
Germany
Sorry for the long wait. Thanks to elnardu's efforts, we were able to add threading support with v0.5.2-alpha and pyimgui with v0.6.0-alpha. This means that you can now use threading and create GUI-based applications for the Switch in Python. See the pyimgui documentation and this example by elnardu.

Changelog:
  • Python threads support
  • zlib support
  • pyimgui support
  • urllib works properly now
  • new PyNX launcher:
68747470733a2f2f692e696d6775722e636f6d2f516974616e586c2e6a7067


Edit: Oh here's the link to the release btw
 
Last edited by AileenLumina,

Maq47

Lord of Pyro
Member
Joined
Jan 7, 2012
Messages
1,240
Trophies
1
Location
Your basement
Website
idont.have.one
XP
3,281
Country
United States
I want to know something: Is there a way to set the archive flag on a folder on the SD card via PyNX's os.stat function, or is there no Switch equivalent to the 'chflags' command available in PyNX? If it would work, can someone provide a sample script to check the archive flag on "sdmc:/tinfoil/nsp/LHPC_split.nsp/", tell me whether it is, and ask me whether I want to set it if it is not set (and actually set it if I type 'Y', and do nothing if I type 'n', obviously)? I don't know the proper syntax that Python uses (not on any version), but I do know that the 'os' module's 'stat' function can do the job.
 

Alex4nder001

Part-time thug
Member
Joined
Jul 28, 2017
Messages
453
Trophies
0
Location
London
XP
1,621
Country
United Kingdom
Sorry for bumping, but does PyNX support Pygame and OpenGL? I'm learning Python OpenGL and once I've created some 3D games I was hoping to port them over to the Switch and play them with PyNX. Also, can I install other packages, like PyAudio? I'd normally use pip on a computer but IDK how to do it in PyNX.
 

TheStonedModder

Well-Known Member
Member
Joined
Dec 25, 2022
Messages
784
Trophies
0
Age
27
XP
1,581
Country
United States
Developers' time is valuable, if they are not financially supported to maintain their projects. But very few offer the source code and it cannot be improved by third parties, as in this case.

https://gbatemp.net/threads/gen7-1-...tch-wii-and-windows-new-major-edition.534418/
While that can be the case for a lot of projects. I dont think it is what happened here. I think the developer just moved onto something else. Since this repo was uploaded 5 years ago and never touched again(there is no documentation at all except for 1 example.)
If you go through the creators Github you can also see this history repeat with the other repos. With all of the ones made after this python where also created/uploaded and never touched again
 
  • Like
Reactions: Cris1997XX

Cris1997XX

Well-Known Member
Member
Joined
Oct 31, 2021
Messages
469
Trophies
0
Age
23
XP
1,259
Country
Italy
While that can be the case for a lot of projects. I dont think it is what happened here. I think the developer just moved onto something else. Since this repo was uploaded 5 years ago and never touched again(there is no documentation at all except for 1 example.)
If you go through the creators Github you can also see this history repeat with the other repos. With all of the ones made after this python where also created/uploaded and never touched again
Yeah...we can see she gets bored quickly
 
Last edited by Cris1997XX,

Imancol

Otak Productions
Member
Joined
Jun 29, 2017
Messages
1,375
Trophies
0
XP
2,762
Country
Colombia
While that can be the case for a lot of projects. I dont think it is what happened here. I think the developer just moved onto something else. Since this repo was uploaded 5 years ago and never touched again(there is no documentation at all except for 1 example.)
If you go through the creators Github you can also see this history repeat with the other repos. With all of the ones made after this python where also created/uploaded and never touched again
I was expecting something from an invester to launch. Creating a Game Development Framework for Homebrew is something I wanted to do. But lacking a donation, I change the name and dedicate it to other platforms.

Had it had the impact that other open source engines had, it would have prospered.
 
  • Haha
Reactions: Cris1997XX

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Psionic Roshambo @ Psionic Roshambo: https://www.youtube.com/@legolambs