ChatGPT Canvas Python: 4 Problems and 1 Partial Solution (Better than 4 Weddings and a Funeral)

ChatGPT Canvas Python: 4 Problems and 1 Partial Solution (Better than 4 Weddings and a Funeral)

I was hoping to write this article after I had found work arounds for most of the problems I've encountered with writing code in the Python Canvas in ChatGPT. But I am only going to be able to partially do that. So here is what I learned so far:

Canvas Python Runs Totally Differently from the Previous Code Execution

When you are using canvas with Python, it is running a totally different way than the code execution that can still happen in the chat frame. And ChatGPT doesn't realize this, without being told.

This made it very confusing for me at first, because they have packages stored in different areas, they were different versions of Python, and of most importance, Canvas Python uses WebAssembly using pyodide. If you aren't familiar with WebAssembly or pyodide, neither am I! :-)

But with playing a bit with it, I started to figure some things out, as I will continue to share.

Sometimes Canvas Executes Old Code that is No Longer There

This was the most frustrating thing for me. Several times, I would get errors or outputs that were clearly from code that was no longer on my canvas. And I was able to verify that it was in fact executing code that I no longer had in canvas, because when I copied and pasted the code into a new chat and new canvas, the error messages went away. So if you get this problem, try starting a new chat.

You will Bump Into Your Usage Cap Much More Often

I am a ChatGPT plus subscriber, and usually with normal chatting, and using the ChatGPT 4o Model, I never run into the usage cap. But, when I use the ChatGPT 4o Model with Canvas for Python, the usage cap gets hit far quicker. This is in fact why I am writing this article without fully figuring everything out, because as I was trying to do more to test out my ideas and fix my code, I ended up being told I couldn't do anything for a while.

ChatGPT Continues to Suck at Debugging

While I really do think that ChatGPT has promise in helping to do programming, it honestly has usually sucked when I have wanted it to do debugging, especially with the 4o Model. For example, it has said "I will fix this by doing xyz" and then when that has an error it will say "I will fix this by doing abc", and then when that has an error, it will not remember what it did before, and say "I will fix this by doing xyz", and so you need to "remind" it at times that it already did that before and it didn't work. Maybe someone has found some custom instructions that work to solve a lot of this, but it is something that I haven't found a good solution to, other than doing a lot of my own debugging.

Use a Project to Set Custom Instructions for your Canvas Pythons

With the new Projects, you can easily set different instructions for different types of things you do. You probably could do this with a custom GPT also, but for my needs, using a Project as a folder was far better. Here are the custom instructions I'm currently using, which also can give you some more information about what I have so far found out about how Canvas Python works:

You will be helping me to write code using the canvas, and its Python interpreter that uses webassembly and pyodide.  Whenever you start, please open a Python canvas, unless told otherwise. Also, unless otherwise told, do all changes of code you suggest in the canvas, and not in the chat.  Please remember that the chat and canvas use two different python interpreters, so it is important to do as much as possible in the canvas.

Please remember that you have access to the following modules:
abc
aifc
antigravity
argparse
ast
asyncio
base64
bdb
bisect
bz2
cProfile
calendar
cgi
cgitb
chunk
cmd
code
codecs
codeop
collections
colorsys
compileall
concurrent
configparser
contextlib
contextvars
copy
copyreg
crypt
csv
ctypes
dataclasses
datetime
decimal
difflib
dis
doctest
email
encodings
enum
filecmp
fileinput
fnmatch
fractions
ftplib
functools
genericpath
getopt
getpass
gettext
glob
graphlib
gzip
hashlib
heapq
hmac
html
http
imaplib
imghdr
importlib
inspect
io
ipaddress
json
keyword
linecache
locale
logging
mailbox
mailcap
mimetypes
modulefinder
multiprocessing
netrc
nntplib
ntpath
nturl2path
numbers
opcode
operator
optparse
os
pathlib
pdb
pickle
pickletools
pipes
pkgutil
platform
plistlib
poplib
posixpath
pprint
profile
pstats
pty
py_compile
pyclbr
pydoc
pyodide
queue
quopri
random
re
reprlib
rlcompleter
runpy
sched
secrets
selectors
shelve
shlex
shutil
signal
site
smtplib
sndhdr
socket
socketserver
sre_compile
sre_constants
sre_parse
stat
statistics
string
stringprep
struct
subprocess
sunau
symtable
sysconfig
tabnanny
tarfile
telnetlib
tempfile
textwrap
this
threading
timeit
token
tokenize
tomllib
trace
traceback
tracemalloc
tty
types
typing
unittest
urllib
uu
uuid
warnings
wave
weakref
webbrowser
wsgiref
xdrlib
xml
xmlrpc
zipapp
zipfile
zipimport
zoneinfo
micropip
packaging

Please also remember that micropip can install pure python packages with the code: await micropip.install("packagename")        

To view or add a comment, sign in

More articles by Jacob Walker

Others also viewed

Explore topics