Python Forum
My first day coding (ever) :/
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My first day coding (ever) :/
Hey, I have just started reading 'Python for programers' and theres an example in the textbook that gets us to execute a script. But the command doesn't work. After looking on Git hub, i see that the author of the book (Paul Deitel) has posted a new, correct command. But it is still not working i keep getting a "syntax error". What am I doing wrong? (p.s. sorry, i am not sure how to upload a photo). Maybe someone else could see if it works for them. Here is the page
I didn't run the code but from what I see, you need at least python 3.6 to run it. What is your version of python?
Thanks for your reply. I'm using python 3.8.3. So i am still not sure of the issue.
Can you post the complete error traceback between error tags?
Look here if you use Windows.
Here a quick run you can look at,i clone Repo and run
λ git clone
Cloning into 'IntroToPython'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 1029 (delta 0), reused 1 (delta 0), pack-reused 1026
Receiving objects: 100% (1029/1029), 13.73 MiB | 3.25 MiB/s, done.
Resolving deltas: 100% (731/731), done.
Checking connectivity... done.
Checking out files: 100% (1136/1136), done.

λ cd IntroToPython\

G:\div_code\IntroToPython (master)
λ ls
IntroToPythonCover.png  examples/

G:\div_code\IntroToPython (master)
λ cd examples\

G:\div_code\IntroToPython\examples (master)
λ cd ch01

G:\div_code\IntroToPython\examples\ch01 (master)
λ ls  snippets_ipynb/

G:\div_code\IntroToPython\examples\ch01 (master)
λ python
ModuleNotFoundError: No module named 'seaborn'

# Install seaborn
G:\div_code\IntroToPython\examples\ch01 (master)
λ pip install seaborn
Collecting seaborn
  Downloading seaborn-0.10.1-py3-none-any.whl 
Successfully installed scipy-1.5.2 seaborn-0.10.1

# Run need command line arguments
G:\div_code\IntroToPython\examples\ch01 (master)
λ python 5 2
[Image: BhDGGS.png]
You need to install some stuff,as matplotlib and seaborn.
This book also do a lot in Jupyter Notebook.
So do install JupyterLab.
I use cmder here,but command is same in cmd.
You may need Git,to clone Repo as i do.
Hey thanks for the help, really appreciate it. I use mac btw. Also i don't understand most of the things you said sorry.

here is what i did:

Last login: Wed Aug 26 11:24:34 on console

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit
(base) Jesses-iMac:~ jessefarquhar$ ipython
Python 3.8.3 (default, Jul  2 2020, 11:26:31) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: cd ~/documents/pythonforprogrammers-master/examples/ch01                

In [2]: ipython -i 6000 1                                     
  File "<ipython-input-2-eeab42d97e89>", line 1
    ipython -i 6000 1
SyntaxError: invalid syntax

In [3]:  
Now you try to run command in interactive shell,that command is meant to be run from command line(Terminal Mac).
So these two the give the same output image as shown if i run them from command line.
python 5 2
ipython Aerodynamically 5 2
On Mac the ipython is the same way,may need python3 if run from Python.
python3 5 2
Also pip most work check with pip -V or pip3 -V command line.
The install eg JupyterLab is like this.
pip3 install jupyterlab
Thanks, i just needed to run it in the terminal rather than interactive shell. How did you know it was meant for the terminal rather than the interactive shell?
(Aug-27-2020, 01:03 AM)jessefarquhar Wrote: How did you know it was meant for the terminal rather than the interactive shell?
Code uses sys.argv which is used to take arguments from command line and pass it to code.
Here i run in colab notebook now you see that have take away sys.argv and give values in code.
Also added %matplotlib inline to show plot in Notebook and not a own window.

Google Colab is fine and free way to run Notebooks no install just use and run.

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020