CMU Template is broken

Problem description: New CMU Template replits do not compile. Error and solution described in this thread Traceback (most recent call last): File "", line 1, in <module> from cmu_graphics import *

Expected behavior: Program compiles and runs

Actual behavior:

Error Traceback (most recent call last):
  File "", line 1, in <module>
    from cmu_graphics import *
  File "/home/runner/FlusteredBlandVisitor/venv/lib/python3.8/site-packages/cmu_graphics/", line 5, in <module>
    main_sibling_filenames = set(os.listdir(main_directory))
FileNotFoundError: [Errno 2] No such file or directory: ''

Steps to reproduce: Create a new Replit using Python CMU Graphics template. Hit Run

Step to Fix: If you follow the instructions on the other post I go into the file and replace that line with the line suggested and the problem goes away 100% of the time.

**Bug appears at this link:**

Browser: Chrome
OS: Windows
Device (Android, iOS, n/a leave blank): laptop
Plan (Free, Hacker, Pro Plan):

I would really appreciate this being fixed so my students can submit their work as I had expected before the semester started.

1 Like

I was able to solve this in another topic.

Looks like cmu-graphics is buggy before python 3.9.
Show hidden files and open the file venv/lib/python3.8/site-packages/cmu_graphics/ .
Replace line 4 with:
main_directory = os.path.dirname(os.path.abspath(__main__.__file__))

To show hidden files:

click the 3 dots next to Files and click Show Hidden Files.


I understand it works. I can’t teach my new programmers in my classes to do this. I need this fixed by replit.

1 Like

That might take quite a while I guess.

I created a solution that is easier to use:
Open shell, then paste in the following command with (Ctrl+Shift+V):
sed -i 's/e(__main__.__file__)/e(os.path.abspath(__main__.__file__))/' venv/lib/python3.8/site-packages/cmu_graphics/

Or maybe get a working repl and have students fork it possibly?


Hey all, we are aware of this bug and have a resolution in progress! I’ll update again here once the template is fixed.


Hello all, the current solution is to:

  1. Add (or modify) run = "python" to the top of .replit
  2. Remove the [interpreter] block from the .replit file, if it exists

Hit run again and it should get around the problem.

We have updated our CMU Graphics template and you may create from that as well.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.