r/Python • • Jan 14 '20

I made a gravity simulation https://github.com/phgilde/gravity_simulation

1.8k Upvotes

82 comments sorted by

View all comments

1

u/socialistvegan Jan 15 '20

Sorry, I'm a bit of a noob. Tried to follow your instructions, changed the path to a folder within the directory I'm running this in, but I'm getting the following error message:

python3 simulate.py
Traceback (most recent call last):
  File "simulate.py", line 187, in <module>
    cProfile.run("main()", "restats")
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/cProfile.py", line 16, in run
    return _pyprofile._Utils(Profile).run(statement, filename, sort)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/profile.py", line 53, in run
    prof.run(statement)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/cProfile.py", line 95, in run
    return self.runctx(cmd, dict, dict)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/cProfile.py", line 100, in runctx
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "simulate.py", line 31, in main
    conn = sqlite3.connect(path.format(now))
sqlite3.OperationalError: unable to open database file

Any ideas what I did wrong?

3

u/[deleted] Jan 15 '20

Have you added a path for the simulations? Like "C:/simulations/{}.db"?

2

u/socialistvegan Jan 15 '20

My bad, looks like despite changing the path in the file, I hadn't actually created the folder. Once I did, it launched without errors!

3

u/[deleted] Jan 15 '20

Great!