1st Online Python Editor With Live Syntax Checking and Execution

Overview

PythonBuddy 🖊️ 🐍

Travis branch Donate
Online Python 3 Programming with Live Pylint Syntax Checking!

Usage

  1. Fetch from repo:
git clone https://github.com/ethanchewy/PythonBuddy.git
  1. Change to PythonBuddy directory
cd PythonBuddy
  1. Create virtualenv based on your own system:
python3 -m venv venv
  1. Activate virtual environment:
source venv/bin/activate
  1. Enusre that your virtualenv uses Python 3.7.6 via this command:
python --version

If you don't use Python Python 3.7.6, some Python libraries that PythonBuddy relies on may not work. Please refer to this documentation for figuring out how to create a specific version of Python via vitualenv via this StackOverflow post.

  1. Pipe requirements to venv folder:
pip install -r requirements.txt
  1. Change to the PythonBuddy application folder. You should now be in PythonBuddy/PythonBuddy/.
cd PythonBuddy
  1. Set FLASK_APP variable:
export FLASK_APP=app.py
  1. Run flask app:
flask run

Open your browser to localhost:5000 . Voila! 🎉

Current Features:


  • Live Syntax Checking
    • Uses Pylint as checker (only prints out errors and warnings)
    • Syntax Highlighting

  • Python Execution
    • Python Complilation
    • Basic Sandboxing

  • Live Error Table with Additional Help Suggestions

  • Secure (Sandboxed) Version using Docker

    Please check out PythonBuddySandboxed for a fully working web implementation which uses a dockerized version of PythonBuddy called PythonBuddySandbox.

    This builds off of christophetd's docker-python-sandbox and just modifies it so that it runs pylint in the background and processes the pylint messages on the client side.

    To see how he implements it on the web side, please check out https://github.com/christophetd/code-execution-api-demo

    This is still in alpha stage so there might be some bugs. If you want to implement this please check the 4 links above since documentation is a WIP.

    Customization Options

    1. Edit app.py to change any pylint options (like showing/hiding hints warnings)
    2. Security
    3. To create a much more secure Python Environment, consider using my Docker + Node.js implementation: https://github.com/ethanchewy/PythonBuddy#secure-sandboxed-version-using-docker
    4. For versions that used Python 2 or to see older versions, check: https://github.com/ethanchewy/PythonBuddy/releases

    Unit Tests

    To run tests, run this at the root directory:

    pytest
    

    For coverage run the following command in the root directory:

    pytest --cov-report html --cov=PythonBuddy tests/
    

    Future Goals:

    • Make easily embeddable for MOOCs like edX and other education platform
    • Create an analytics system that models the student's python learning and tells them where they need improvement (many programming students learn by copying and pasting and don't actually understand the nuances of the Python language).
    • Stricter Python Sandboxing via Pypy's sandboxing solution
    • Lower CPU usage
    • Allow users to generate a link to a unique code snippet similar to JSBin
    • Unit tests for client side JS

    FAQ:

    Why did you make this?
    In 2014, I was a Community TA at MIT edX 6.00.1x course where I helped teach over 1000 students. The year after I started researching under Prof. Eni Mustafaraj. She had a data set from that course and we saw a high attrition rate of students within the first 2 weeks. After digging through the curriculumn and data, I realized that the students left because of difficulties setting up their Python environment and complex error messages that they couldn't solve when running their code (ex: some students had path issues).

    So, I created PythonBuddy to address this issue so that students wouldn't have to go through the frustrations of setting up a Python environment and running into seemingly "random" bugs. PythonBuddy allows users to jump right into Python programming with the support of live syntax checking & highlighting. Also, professors and teachers could easily set up a server and allow students to quickly test out their code with PythonBuddy online.

    Has anyone created anything like this before?
    There has never been a live syntax checker for python online. Similar projects that are not "live" are http://pep8online.com/ and http://antares.sip.ucm.es/cesar/pylint/

    How can I contribute?
    You can 🌟 star my repo, fork my repo, submit a pull request, and/or open issues!

    Where's the code for embedding it in MOOCs?
    I'm currently working on this over here (for edx specifically): https://github.com/ethanchewy/pybuddy2.0 . If you want to embed this project directly to your site, you would use an iframe:

    <iframe src="https://pythonbuddy.com"></iframe>
    

    I want the code to actually compile and run in a certain way?
    To run PythonBuddy securely, you can check out my implementation of PythonBuddy with Docker and Node.js: https://github.com/ethanchewy/PythonBuddy#secure-sandboxed-version-using-docker. Basically, it dockerizes each user session (similar to creating a virtual machine for each user) and destroys it if it uses too much memory or runs malicious code.
    If you want to actually execute the python in a restricted fashion at my Restricted Python branch: https://github.com/ethanchewy/PythonBuddy/tree/restrictedpython.

    How do I run my own server? Regular: https://github.com/ethanchewy/OnlinePythonLinterSyntaxChecker/wiki
    Sandboxed: https://github.com/ethanchewy/PythonBuddy/wiki/Running-Sandboxed-PythonBuddy

    Press:

    Featured on FlaskCon 2020, Python Weekly, CSS Author, and the Talk Python Podcast

    Credits:

    This was made by Ethan Chiu as a research project under the guidance of Wellesley College professor Eni Mustafaraj.

    Other:

    As of October 2020, PythonBuddy.com will no longer be a demo server for this open-source project due to the increasing costs of hosting it for 80,000+ people monthly. Instead, this URL will redirect back to this GitHub repo.

    How can I support PythonBuddy?

    If you enojyed using this open-source project, please consider donating whatever you can to these organizations that address problems I'm passionate about:

    If you don't have the means to donate to the above, consider checking out some of these free action items and information:

    Comments
    • Update demo gifs with newest version of PythonBuddy

      Update demo gifs with newest version of PythonBuddy

      Problem:

      • GIFs in current Readme(https://github.com/ethanchewy/PythonBuddy/blob/master/README.md) show the earliest version of PythonBuddy.

      Goal:

      • Produce GIFs of the most current version of PythonBuddy and update them in the Readme

      How to do this?

      • Follow Readme instructions on installing
      • Check out what GIFs are currently displayed in README and take videos of exactly the same functions but wiht updated PythonBuddy
      • Load up PythonBuddy in local browser and take screenvideos of site.
      • Convert those clips to GIFs and update readme
      Hacktoberfest 
      opened by ethanchewy 15
    • KeyError: 'file_name' by clicking on the Run button

      KeyError: 'file_name' by clicking on the Run button

      Describe the bug When I start the app, my first test was click on Run button and I've received KeyError: 'file_name'. Before run the app, i've needed to update werkzeug to the last version cuz with the version in requirements.txt the app cannot be run

      To Reproduce Steps to reproduce the behavior:

      1. start application with Flask run (werkzeug updated)
      2. Click on Run button
      3. open your terminal
      4. See error

      Screenshots xxxx

      Desktop (please complete the following information):

      • OS: Ubuntu 20 // windows 10
      • Browser Firefox

      Additional context It happens on my Windows PC and Ubuntu too.

      opened by LeonardoFurtado 9
    • package typed-ast older versions doesn't work on python 3.8?

      package typed-ast older versions doesn't work on python 3.8?

      Hi, Ethan ✌ I just set PythonBuddy in my WSL installation and during the installation of the required packages an error was raised. I was able to fix it so I'm posting the step here in case anyone is interested.

      Steps to reproduce the behavior:

      1. Ubuntu 20.04 on Windows Subsystem for Linux
      2. Python 3.8
      3. Clone the repo, create a virtualenv for it
      4. Try to install the required packages and get the following error:
          Running setup.py install for typed-ast ... error
          ERROR: Command errored out with exit status 1:
           command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-tr7ufsax/typed-ast/setup.py'"'"'; __file__='"'"'/tmp/pip-install-tr7ufsax/typed-ast/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-qwpgruzh/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/marcelo/.local/include/python3.8/typed-ast
               cwd: /tmp/pip-install-tr7ufsax/typed-ast/
          Complete output (23 lines):
          running install
          running build
          running build_py
          creating build
          creating build/lib.linux-x86_64-3.8
          creating build/lib.linux-x86_64-3.8/typed_ast
          copying typed_ast/__init__.py -> build/lib.linux-x86_64-3.8/typed_ast
          copying typed_ast/ast27.py -> build/lib.linux-x86_64-3.8/typed_ast
          copying typed_ast/ast3.py -> build/lib.linux-x86_64-3.8/typed_ast
          copying typed_ast/conversions.py -> build/lib.linux-x86_64-3.8/typed_ast
          running build_ext
          building '_ast27' extension
          creating build/temp.linux-x86_64-3.8
          creating build/temp.linux-x86_64-3.8/ast27
          creating build/temp.linux-x86_64-3.8/ast27/Parser
          creating build/temp.linux-x86_64-3.8/ast27/Python
          creating build/temp.linux-x86_64-3.8/ast27/Custom
          x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iast27/Include -I/usr/include/python3.8 -c ast27/Parser/acceler.c -o build/temp.linux-x86_64-3.8/ast27/Parser/acceler.o
          ast27/Parser/acceler.c:13:10: fatal error: pgenheaders.h: No such file or directory
             13 | #include "pgenheaders.h"
                |          ^~~~~~~~~~~~~~~
          compilation terminated.
          error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
      

      Expected behavior ´´pip3 install -r should execute without errors´´

      I managed to fix this by upgrading the version of the package that is being accused of raising the error. Someone at Stackoverflow had a similar issue and the solution worked for me here too. Solution:

      Upgrading to typed-ast==1.4.1 worked for me using Python 3.8.5

      After the solution was applied I could install the required packages without errors.

      opened by marceloFA 5
    • Fix Line Number Error on Restricted Python branch

      Fix Line Number Error on Restricted Python branch

      Here's the branch that needs to be fixed: https://github.com/ethanchewy/PythonBuddy/tree/restrictedpython

      Error is pretty simple. The code runs fine and is linted. The line numbers just have to be adjusted correctly. Right now, it displays negative line numbers

      To contribute:

      • Fork this branch.
      • Follow installation instructionsfor testing:
      • Open a pull request and describe your changes. Please only submit fully functional pull requests.
      • If you have any questions, leave it in this thread.
      • Please only do testing on your own local version of PythonBuddy!!

      Contributors who are approved for pull requests and make significant contributions will be attributed in the Contributing.md file

      bug Hacktoberfest 
      opened by ethanchewy 5
    • The solution for Line Number issue

      The solution for Line Number issue

      Seems like windows and Linux has different error formats, so Linux has line number on position [1] and Windows on position [2] (when you split string by ":")

      opened by vladimir-kirillovskiy 4
    • Adds support for coveralls

      Adds support for coveralls

      Adds setup in .travis.yml to run coverage in travis and report coverage to coveralls.io

      Generated artifacts: https://travis-ci.org/chaps/PythonBuddy/builds/595634318 https://coveralls.io/github/chaps/PythonBuddy

      opened by chaps 3
    • This looks great

      This looks great

      Just exactly what I need. Thank you so much for all of the hard work.

      Forgive me if I make one comment. There are really two parts to this. One is the core server functionality. And the other is the flask app which calls it.

      For those of us who are not using Flask, it would be nice if they were in separate files. Then I would not have to import all of flask to use it.

      Otherwise, it looks like lots of hard work has been done by EthanChewy.
      Thank you so much.

      opened by PythonLinks 3
    • fix example #2 bug

      fix example #2 bug

      For example two, the example code is:

      methods = []
      for i in range(10):
          methodds.append(lambda x: x + i)
      print methods[0](10)
      

      Could you change it to this:

      methods = []
      for i in range(10):
          methods.append(lambda x: x + i)
      print methods[0](10)
      
      opened by Vic-ST 3
    • Make Python Execution More Secure

      Make Python Execution More Secure

      Ideas for achieving this:

      • Using Restricted Python. Check out my branch over here: https://github.com/ethanchewy/PythonBuddy/tree/restrictedpython I basically finished it's implementation. I want to make it a little bit more flexible. The only bug over there is the line number that is being displayed.
      • Process it using PyPy sandbox: http://doc.pypy.org/en/latest/sandbox.html .

      Resources:

      Other Implementations of Python Sandboxes to look at:

      To contribute:

      • Open a pull request and describe your changes. Please only submit fully functional pull requests.
      • If you have any questions, leave it in this thread.
      • Please only do testing on your own local version of PythonBuddy!!

      Thanks!

      Contributors who are approved for pull requests and make significant contributions will be attributed in the Contributing.md file

      Hacktoberfest 
      opened by ethanchewy 3
    • Fix PythonBuddy not working in Windows

      Fix PythonBuddy not working in Windows

      Line Numbers do not show up correctly when PythonBuddy is running on a Windows system.

      Thank you @DirtySoc for raising this up and providing these screenshots: Windows 10 1803 w/ Python3.7: 47252013-2547ee80-d40b-11e8-9fcc-6ebad2e17c44

      Ubuntu 18.01 w/ Python3.6.6: 47252254-a99c7080-d40f-11e8-93f7-7f07dbbbf819

      PythonBuddy was developed for Unix systems so it works on Mac and Ubuntu for example. Unfortunately, the line numbers are not processed correctly in PythonBuddy for Windows. My hunch is that in app.py the data passed in the AJAX calls is formatted differently in Windows systems. Or, there is an issue with creating temp files in Windows system.

      bug Hacktoberfest 
      opened by ethanchewy 2
    • HTTP 414 Request-URI Too Large

      HTTP 414 Request-URI Too Large

      If the code is longer than the server specified allowed request limit (seemingly 8KB) a HTTP 414 error is returned. This is because HTTP GET is used, and can easily be fixed by using HTTP POST.

      E.g. replacing in javascript.js: https://github.com/ethanchewy/PythonBuddy/blob/895ecbcbbe4e7053913af4b60365cf1c3c31f7b1/static/js/javascript.js#L88-L95

      With this:

      $.post('/check_code', {
          text :  code
      }, function(data) {
          current_text = data;
          //Check Text
          check(current_text);
          return false;
      }, 'json');
      

      If this limit is intentional, then there are still better ways to handle it than just "crashing". E.g. just checking the length of the string to be sent to the server beforehand, and telling the user that is the case.

      opened by Chessax 2
    • Who to contact for security issues

      Who to contact for security issues

      Hello 👋

      I run a security community that finds and fixes vulnerabilities in OSS. A researcher (@evanottinger) has found a potential issue, which I would be eager to share with you.

      Could you add a SECURITY.md file with an e-mail address for me to send further details to? GitHub recommends a security policy to ensure issues are responsibly disclosed, and it would help direct researchers in the future.

      Looking forward to hearing from you 👍

      (cc @huntr-helper)

      opened by benharvie 3
    • Deployment on Vercel

      Deployment on Vercel

      Is your feature request related to a problem? Please describe. For easy usage to users, we can deploy it on vercel @vercel

      Describe the solution you'd like Using this: https://vercel.com/docs/runtimes#official-runtimes/python

      Describe alternatives you've considered Heroku Can be used, but it is difficult to configure. Also, its response time is slower in some regions.

      opened by Siddhant-K-code 1
    • Add History of Code Submissions

      Add History of Code Submissions

      As a user, I want to be able to view my previous code submissions.

      Since PythonBuddy is only for 1 user for this repo (for PythonBuddySandboxed aka the demo server, it's different), we can achieve this by either

      1. creating a database and storing each of the submissions. OR
      2. using window.localstorage https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
      opened by ethanchewy 4
    • Port to PyOdide

      Port to PyOdide

      PyOdide is cPython compiled to WebAssembly and running in the browser.

      If PyLint is pure python, it is quite easy to run it on top of Pyodide, in the browser. If PyLint includes C code, it is not that hard to port it to Pyodide. There is a well developed tool chain.

      Then Python Buddy could run entirely in the browser. No server would be required. I would use it in the ForestWiki.com

      I hope that helps. Christopher Lozinski PythonLinks.com

      opened by PythonLinks 26
    Releases(v3.0.0)
    • v3.0.0(Oct 29, 2020)

      In this release, we updated the packages that Python Buddy relies on. Before, there were bugs with those packages but they have now been fixed so these changes will now fix all Windows compatibility issues and update us to Python 3.7+.

      Source code(tar.gz)
      Source code(zip)
    • 2.0.2(Oct 29, 2018)

    • 2.0.0(Aug 8, 2018)

      The following release implements the following:

      • multiprocessing to handle multiple errors
      • verbose null checks
      • fix various bugs in cm-validator.js and javascript.js that prevented some errors and warnings from being presented
      • leverage sessions to handle multiple users at scale
      • redesign code to make more readable/cleaner
      • Update pylint and error messages related to pylint for more info (from pylint --list-msgs)
      • Process pylint messages on server side now.
      Source code(tar.gz)
      Source code(zip)
    Owner
    Ethan Chiu
    code for humanity
    Ethan Chiu
    A "multiclipboards" script for an efficient way to improve the original clipboards which are only able to save one string at a time

    A "multiclipboards" script for an efficient way to improve the original clipboards which are only able to save one string at a time. Works on both Windows and Linux.

    1 Jan 24, 2022
    A comparison of mesh generators.

    This repository creates meshes of the same domains with multiple mesh generators and compares the results.

    Nico Schlömer 29 Dec 12, 2022
    Msgpack serialization/deserialization library for Python, written in Rust using PyO3 and rust-msgpack. Reboot of orjson. msgpack.org[Python]

    ormsgpack ormsgpack is a fast msgpack library for Python. It is a fork/reboot of orjson It serializes faster than msgpack-python and deserializes a bi

    Aviram Hassan 139 Dec 30, 2022
    Wagtail + Lottie is a Wagtail package for playing Adobe After Effects animations exported as json with Bodymovin.

    Wagtail Lottie Wagtail + Lottie is a Wagtail package for playing Adobe After Effects animations exported as json with Bodymovin. Usage Export your ani

    Alexis Le Baron 7 Aug 18, 2022
    A simple spyware in python.

    Spyware-Python- Dependencies: Python 3.x OpenCV PyAutoGUI PyMongo (for mongodb connection) Flask (Web Server) Ngrok (helps us push our fla

    Abubakar 3 Sep 07, 2022
    Update your Nintendo Switch cheats with one click, or a bit more~

    Interactive-ASM-Cheats-Updater This updater unlocks your ability of updating most of the ASM cheats for Nintendo Switch. Table of Contents Functions Q

    zzpong 63 Dec 27, 2022
    Framework To Ease Operating with Quantum Computers

    QType Framework To Ease Operating with Quantum Computers Concept # define an array of 15 cubits:

    Antonio Párraga Navarro 2 Jun 06, 2022
    Mute your mic while you're typing. An app for Ubuntu.

    Hushboard Mute your microphone while typing, for Ubuntu. Install from kryogenix.org/code/hushboard/. Installation We recommend you install Hushboard t

    Stuart Langridge 142 Jan 05, 2023
    This repo presents you the official code of "VISTA: Boosting 3D Object Detection via Dual Cross-VIew SpaTial Attention"

    VISTA VISTA: Boosting 3D Object Detection via Dual Cross-VIew SpaTial Attention Shengheng Deng, Zhihao Liang, Lin Sun and Kui Jia* (*) Corresponding a

    104 Dec 29, 2022
    I³ Tracker for Essential Open Innovation Datasets

    I³ Tracker for Essential Open Innovation Datasets This repository is set up to track, version, and contribute updates to the I³ Essential Open Innovat

    1 Feb 08, 2022
    Cirq is a Python library for writing, manipulating, and optimizing quantum circuits and running them against quantum computers and simulators

    Cirq is a Python library for writing, manipulating, and optimizing quantum circuits and running them against quantum computers and simulators. Install

    quantumlib 3.6k Jan 07, 2023
    This is a library for simulate probability theory problems specialy conditional probability

    This is a library for simulate probability theory problems specialy conditional probability. It is also useful to create custom single or joint distribution with specific PMF or PDF to get probabilit

    Mohamadreza Kariminejad 6 Mar 30, 2022
    Removes all archived super productivity tasks. Just run the python script.

    delete-archived-sp-tasks.py Removes all archived super productivity tasks. Just run the python script. This is helpful to do a cleanup every 3-6 month

    Ben Herbst 1 Jan 09, 2022
    A simple and easy to use Python's PIP configuration manager, similar to the Arch Linux's Java manager.

    PIPCONF - The PIP configuration manager If you need to manage multiple configurations containing indexes and trusted hosts for PIP, this project was m

    João Paulo Carvalho 11 Nov 30, 2022
    Repo with data from local elections in Portugal from 2009 to 2013

    autarquicas - local elections in Portugal Repo with data from local elections in Portugal from 2009 to 2013 Objective To provide, to all, raw data fro

    Jorge Gomes 6 Apr 06, 2022
    Problem statements on System Design and Software Architecture as part of Arpit's System Design Masterclass

    Problem statements on System Design and Software Architecture as part of Arpit's System Design Masterclass

    Relog 1.1k Jan 04, 2023
    Context-free grammar to Sublime-syntax file

    Generate a sublime-syntax file from a non-left-recursive, follow-determined, context-free grammar

    Haggai Nuchi 8 Nov 17, 2022
    A country information finder module

    A country information finder module

    Fayas Noushad 3 Nov 28, 2021
    Predicting Global Crop Yield for World Hunger

    Crop Yield And Global Famine - The fifth project I created during my time at General Assembly. I completed this project with three other classmates in the span of three weeks. Most of my work was dir

    Adam Muhammad Klesc 2 Jun 19, 2022
    Swubcase - The shitty programming language

    What is Swubcase? Swubcase is easy-to-use programming language that can fuck you

    5 Jun 19, 2022