AllenDowney / ModSimPy

Text and supporting code for Modeling and Simulation in Python
https://allendowney.github.io/ModSimPy/
MIT License
823 stars 1.76k forks source link

What is the `show` function? #87

Closed ahelwer closed 10 months ago

ahelwer commented 10 months ago

In chapter 2 of the textbook the show function is used to display the bikeshare state. Where is this function defined? I am trying (fairly successfully) to run the textbook in my local python environment instead of a workbook.

AllenDowney commented 10 months ago

It's in modsim.py https://github.com/AllenDowney/ModSimPy/blob/master/modsim.py#L700

So you should get it when you from modsim import *

ahelwer commented 10 months ago

Thanks Allen. Unfortunately this does not work for me. If I have a directory with the following requirements.txt:

pandas
sympy
beautifulsoup4
lxml
html5lib
pint
modsimpy
matplotlib
numpy
scipy
seaborn
tornado
IPython

and the following test.py file:

from modsim import *
print(show)

and then I run the following:

python -m venv .
source ./bin/activate
pip install -r requirements.txt
python test.py

then I get the following error:

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    print(show)
          ^^^^
NameError: name 'show' is not defined
AllenDowney commented 10 months ago

modsim.py is not a package you can install. It is just a file (a Python module) you can download. The notebook should contain code that downloads the file to the current directory, and then you should be able to import it.

If that doesn't work, I strongly encourage you run the notebooks on Colab. The book is really about Modeling and Simulation -- if you spend your time and effort debugging your software development environment, you will never get to the fun part!

In general, if there's a problem running the notebook on Colab, I will fix it. But I can't debug problems with local installations of Python and Jupyter -- sorry, but it's just too much!