Let me go over what I have done so far with ex25.py in the LP3THW book. I copied all the code on page 90 in Notebook ++. I opened it in Win Powershell. After correcting a few mistakes and running it again, all I get is the path. I assume that is all I’m supposed to get. Then I opened it in the Python 3.6 and get all sort of errors, even though I’m doing it like the book says to. I looked through the other posts and I guess I’m supposed to type ’ import from ex25 ’ or something like that? The book doesn’t say that. All that happens is when I type import ex25, (dropping the .py) I get error messages. I have tried typing ‘python ex25’ or ‘lpthw ex25’ ‘python lpthw ex25’ and all I get is Python not defined or things like that. Now I’m both confused, and Not2smart.
@Not2smart you have to post a screen shot or the error messages for us to help. Otherwise it’s like you saying “I don’t feel well” to a Dr and expecting a specific diagnosis without any more info.
Well the thing is that I don’t even know what I’m doing wrong. The book doesn’t give enough information that I can see. After the prompt comes up with the >>>, it says in the book to enter in import ex25. What I should have said is, at the prompt don’t you have to enter in some sort of path like you do in Windows PowerShell? I tried C:\users\Ric\lpthw python ex25 but that is not right, or is it? First I want to get the path right, then I will worry about the error messages. Thanks in advance. Not2smart.
Alright, first thing I say right in the WYSS section is:
“In this exercise we’re going to interact with your ex25.py file inside the python3.6 interpreter you used periodically to do calculations. You run python3.6 from the terminal like this:”
Then right under that is a literal output of me running python to get started.
$ python3.6 Python 3.6.0rc2 (v3.6.0rc2:800a67f7806d, Dec 16 2016, 14:12:21) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>>
You know that the
$ is the command prompt where you type commands. Then I type python3.6 and hit enter. You might have python3.8 installed, so try just python.
This starts the python shell, which is like powershell, but instead of prompting with
$ to run commands, the Python shell prompts with
>>> to run python.
After this, there is a list of python commands you are supposed to type, one at a time, in an interactive way. Every time Python shows you
>>> you type the next thing.
If you are getting errors when you type
import ex25 then you have errors in the file you typed and I suspect I know why:
You are most likely blasting out all of the code in one session without doing any copy editing, review, or running it repeatedly while you code. I suggest you do this:
- Delete that ex25.py file.
- Start again, and type in 1 function of code at a time.
- Stop typing. Now, do a full review of your code vs. my code from the top to the bottom comparing every little thing. I find it helps to read this outloud.
- Fix everything you find that is different.
- Run it with:
python ex25.pybut keep in mind that this will not print out anything if you have no syntax errors. Basically you want it to be silent. If you get errors go fix them.
- Repeat this for all of the other functions, then to the WYSS section.
Finally, are you watching the videos? I literally use Windows 10 to do this, so it should be a way for you to figure out what to do.
Last thing, I know you keep saying you’re not smart, but I don’t see you as not smart, I see you as impatient. It seems your expectation of programming is you type out code in your mind one time in a single fluid motion and then it works, but that’s not how anyone codes. I make tons of mistakes and code very methodically and slowly, building my code gradually and running it constantly. Always Be Running. I feel like your real issue is you don’t have the patience to really run the code, re-read instructions, walk through step by step, and study what’s there. Instead, you slam out some code and guess at how to run it and if it doesn’t go the way you expect then you give up as a failure.
But, you aren’t a failure. You’re just not taking enough time and slowing down to really do it clearly and slowly with a gradual methodic pace. For example, I literally have the command you need to type in the instructions with the output you should see in a section called “What You Should See”. In your hurry to finish this you just kind of skipped over that? I also have a video, and in your hurry to finish this you…didn’t watch it?
So, try to slow down and take this more gradually than you are. You are not stupid at all. You’re just in a hurry for some reason and you don’t need to be. Slow and plodding is going to win this.
Zed: Thanks for getting back to me. I will type in ex25 over again but when I finished typing it in, corrected it and saved it, then ran it in the WinPS, it just came up with a new path. I guess that is what it was supposed to do. When I opened it in Python, I first had to put in the path, right? After the >>> I put in C:\ users\Ric\python ex25 . (No period.) I hit enter to move to the next line and got the error. I’ll try the whole thing over again and copy down the error messages if any. As for the videos, if you are talking about yours, they are $200 and I’m a little low on the cash right now due to a stupid purchase of a Cadillac that needed a lot money put into to it just before the engine blew up. I have watched some of the ones by Burton somebody at the library but they are not all the helpful. As for the name Not2smart, it is mainly in jest. Not2smart.
I would suggest that you start over again.
And do EVERY study drill.
You will gain from this in the long run.
Trust me. I tried to rush through the book.
What? No! There’s a video for each of the exercises in LPTHW. If you own the book, you should have access to them on the website.
First to Florian, I’ll look again into the videos. Now before I throw the baby out with the bath water and delete my file of ex25, I want to make sure a few things are right with my path, and show the error message I get. In Python 3.7, the raw file that I used to do simple math, after the prompt that looks like this, >>> I typed c:users\Ric\lpthw\python\ex25 .(I didn’t put a period in the path.) I got the error message that says 'unexpected character after line continuation character '. There was the ^symbol at the 5. I did a Google search and they talked about things that didn’t apply. I hate to retype the whole file if the problem can be found here, but I will if need be. Any ideas what I did wrong or is it still probably in my code copying? I’m good looking, but …Not2smart.
When you have:
you should not type ”c:users\Ric\lpthw\python\ex25”.
Not in this exercise. And not just like that if you where going to use in Python.
You could in powershell do:
(If ex25 is a folder)
To get to where your ex25.py file is.
Or to run the file from C:
python c:users\Ric\lpthw\python\ex25 ex25.py
Better would be from folder ”Ric”
python lpthw\python\ex25 ex25.py
Best would to be in the folder where the file is.
Or one folder above.
I had an extra read about this exercise.
Forget about what I explained about running the file (for this lesson).
But cd into the folder where your ex25.py is located before starting a Python shell.
Then do as Zed explained.
Couldn’t explain it better.
@Not2smart did you complete the intro to command line steps appendix? That might help you if you’re unclear about navigating file structures and dropping in/out of the Python interpreter
No, I didn’t know of such a thing, or that I was supposed to.
Ulfen69’s path has two ‘Pythons’ in it. That confuses me. Oh well!
The first ”python” is for telling the computer I want to use Python to run this file.
The other ”python” is one of the folders in your path (a folder in your computer).
You should really have a look at the appendix covering how to use powershell (if you have Windows) or terminal (if you have a Mac).
It is VERY useful knowledge.
Absolutely read / do the Appendix A. It is highlighted in Exercise 0 in the book in the setup and is called out fairly well…
GpKesley: Ok, I’ll look that over again. I didn’t find much in it the first time I read it over. Maybe now I will understand it better. I wondered why the path had Python in it twice, being that I never saw anything in the previous lessons to show you that. From my previous learning of DOS, the path always seemed to be a little backwards as I pointed out in a previous post. I won’t bother you guys for a while now, I will try to figure it out myself and reread the book. Thank you. Not2smart. P.S. In these cold Wisconsin winter days, that is about all I feel like doing anyway.
So @Not2smart, the course isn’t $200 it’s $29.99 but a couple other things seem kind of off in how you describe doing things. I’d like you to email me at firstname.lastname@example.org and tell me about any limitations you’re working with. I’ll also give you free access to the videos for the course. It might take me a day or two because I’m traveling in Tbilisi, but I’ll get it to you. Then I want you to start the course over but with the videos this time.
Ok, I did a bunch of research and decided to take this one step at a time and see if I can find my mistake. First, all the commands for the command line listed above do not work. 2nd, I looked up what is a module on line and in my other book and if I have this right, it is sort of like a file inside a file that you import so that you don’t have to write a lot of code. As my other book says, write as little code as you can is the object of a good programmer. 3rd, I went to the library where they have high speed connections and watched the video by Burton (I forget his name) on ex25. He doesn’t put in any thing after the >>> prompt except the command ‘import ex25’. 4th, at this point I return to my computer and launch Python 3.7 from the icon on my desktop. It loads up and has the lines of info as is on page 91 of the book, with the >>> prompt.
(That is due to clicking that box when I installed it that said something about put the path in there, right?) 5th, I type import ex25 and what I get is ModuleNotFoundError: No module named ex25. This is what has bothered me from the start, is that supposed you be in a separate folder named Pathpython or something? Zed doesn’t mention that till the end of the book so I don’t think that is what is wrong. So please tell me, after I get the prompt, what am I to put in? According to the book, just import ex25, but that doesn’t work. Thanks. Not2smart.
@Not2smart read Zed‘s comment above. He wants to help you out.
But it’s worth knowing that software can behave slightly differently on different machines, due to quirks in your bespoke step up, conflicts with other programmes and versions of software installed.
The good thing about Zed’s videos is that you learn ‘why’ you do things and that helps you solve your own problems when you hit new issues.
As an example, I’ve been following a tutorial online to built a Facebook/Twitter clone but it was written a couple of years ago. In that time, some of the modules (you now know what these are ) have been updated. And it breaks what I’ve followed. But I’m not defeated by this, it’s now a challenge to understand and work out how to fix it. That’s the fun of programming.
I would like to help you with your fifth question.
First. Are you using Python Idle?
It can be used. But I recomend you strongly to use Powershell instead.
If you haven’t installed Powershell yet, do so!
Start it up and first check where “it is” with the command: pwd
(print working directory).
It will probably look like: C.\User\Ric
Then you run the command: ls
This tells you what files and folders you have where Powershell is at the moment.
Before you start up a Python shell you have to make sure your file (ex25.py) is in the directory.
If not you can go there with the command: cd Ric\lpthw_directory\ex25_directory
If you see "ex25.py when doing the ls command you can start a python shell and import ex25.
The error message you got is because the file (ex25.py) isn’t where you started the python shell (Idle, Powershell or other terminal).
Try this and tell us how you get on.
Ulfen69: My ex25.py is in the same directory that all my files are in. That is lpthw. I can see it in the list of recent files in Notepad++ and in doing the commands in the Python3.7 terminal. I have deleted the first copy of ex25 like Zed told me to, and rewrote the whole thing over. I have tried about every path that I can think of and still don’t get any thing but errors. It seems so simple from the book, but Zed doesn’t tell you what to put in after the prompt. The way he makes it sound is that after the prompt you just type in import ex25. But you would have to go to the place where the file is located. So I assume you would put- C:Users\Ric\lpthw\python\ex25 just like other lessons.When I do that I get a caret at the last letter or number that says ‘unexpected character after continuation character’. Should I drop any of the parts of my path?I know I’m maing some simple error, and it is driving my nuts trying to find it. Thank you. Not2smart.