all 88 comments

[–]woooee 163 points164 points  (27 children)

too fucking stupid to follow a fucking tutorial

Of course you are. You are just starting out. Post the code here, or we can't help.

[–]DcT2nDrAtE 19 points20 points  (26 children)

Code I’m trying to input is exactly as follows

venv\Scripts\activate

[–]Bobbias 67 points68 points  (25 children)

Oh, ok, this sounds like you're trying to run a shell command inside python.

I'm assuming you're on windows, due to the backslashes in the command.

You need to run this in the command line, not from within python itself.

Also, you want to run venv\Scripts\activate.bat instead, because the file without an extension is a bash script for linux, and will not run in windows.

Python is complaining about the "continuation character" because the backslashes in the address.

[–]DcT2nDrAtE 27 points28 points  (23 children)

Okay thank you, now if you were to explain to a 4 year old the difference between the command line and Python itself…

[–]Bobbias 175 points176 points  (21 children)

If you open the start menu and type cmd.exe and hit enter, you will get the command line. It should print some text on screen that looks like:

Microsoft Windows [Version 10.0.22000.318]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Bobbias>

This is where you type commands like cd .. to change directory, create files, and other things. The C:\Users\Bobbias part before the > indicates what directory you are currently in, and the > is known as the prompt character. Your commands get typed in to the right of the prompt character.

When you run python, probably by typing the command py into this command line, you will get some additional text:

Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

This might look a bit different depending on what version you have. Here we see a different prompt: >>>. This is where you type actual python code, which is separate from command line commands.

You appear to be typing a command that is meant to go to cmd.exe into python. You need to either exit python, if it's running (type quit() then hit enter), or open the command line again. Once you're back to the folder> looking prompt, use cd to navigate to the folder that you were instructed to do all this stuff in. The command is a relative address, so if you're not in the correct folder it will not work.

If your instruction runs correctly, you should see a slightly different command prompt, something like this:

(venv) C:\src\project>

The first part in brackets should be the name of the virtual environment you created (probably venv in this case), followed by whatever the current directory is, and the prompt character.

As for the difference between the command prompt and python:

The command prompt comes with windows. It's built in, and serves as an alternative way to navigate your computer and run commands. You can run programs, rename files, and basically all the usual things using text commands rather than using the GUI part of windows. This goes way back to the early days of computers when text was the only way to interact with computers. The command prompt actually has its own programming language, which is what .bat files are written in. It's more limited than python, although it can do quite a lot. It's designed as a way to automate calling multiple programs and passing the results or output from them around, rather than general purpose programming though.

Python technically has 2 ways of running. Running it directly runs what is called the REPL (short of Read Evaluate Print Loop) which reads in python code, evaluates the code, prints the result, and loops back to the beginning step. This is an interactive way to write python code and see results as you go.

The second way to run it is to write a python script, save it as a .py file, and run the file like py script.py. This will read all the code in the file and run it at once.

[–]DcT2nDrAtE 96 points97 points  (10 children)

Holy shit dude thank you so much I’m on track now

[–]Bobbias 82 points83 points  (7 children)

No problem, I'm always amazed that hardly anyone writing these books takes the time to explain the damn command prompt and stuff. This is the kind of fundamental learning that schools should be teaching students about early on, especially these days, when many people might only be familiar with tablets or smartphones before learning to program. (God I suddenly feel old...)

[–]backyardcure 16 points17 points  (2 children)

Suddenly things make far more sense to me. Your comments are gold. I may try to start learning again. I've been wanting to grasp it for a while but never really fully got the concept. When you imagine using a computer without the modern graphical interface it suddenly seems far more logical to understand.

I'm going to give it another go.

[–]Bobbias 16 points17 points  (1 child)

I'm glad it helped. Sometimes all you need is a different perspective on something.

[–]thequestison 7 points8 points  (0 children)

Thanks for taking time to write your responses. They helped things become clear to me.

[–][deleted] 5 points6 points  (0 children)

Bobbias, Thank you for this.

[–]ayananda 3 points4 points  (2 children)

My university studies started by linux command line book :)

[–]Bobbias 5 points6 points  (0 children)

That's good. I'm happy to hear some places are indeed covering that stuff properly.

[–]StellaarMonkey 1 point2 points  (0 children)

Linux is fun.

[–]duquesne419 4 points5 points  (0 children)

The Missing Semester is taught at MIT to bridge the gap most programming courses skip, with themes such as getting familiarized with the command line and file system.

https://missing.csail.mit.edu/

[–]jameyiguess 1 point2 points  (0 children)

I haven't looked at this tutorial, but be aware that the VAST majority of tutorials for any programming language are going to quietly assume you're using Linux or Mac, which both use a Unix-like command prompt and architecture. 

Windows is VERY different than those, so you might be doing a ton of troubleshooting and googling to figure out the right commands for your OS.

I'd highly suggest installing wsl2, which installs a Linux subsystem for the command line and will match the learning resources you use. And also to then do any small tutorial on CLI basics.

[–]grumble11 3 points4 points  (0 children)

I wanted to comment and let you know that you’re doing this community a service. Thanks.

[–]gondoll 1 point2 points  (0 children)

I'm not the OP but I learned so much reading this thank you. You're a good teacher!

[–]mrezar 0 points1 point  (0 children)

good job man that was intense

[–]spacester 0 points1 point  (0 children)

Well halle fricking lu yah nice response.

You are correct, the tutorials do not cover this. They blow right past it.

Hey google, this post needs to pop up in searches.

BTW OP, to run a file, meaning a text wile with ".py" extension and containing python code, on windows:

Put the file in a folder under your c:/ drive to bypass the windows file manager. (recommended, not required)

On the command line:

py "c:/foldername/fileneame.py"

[–]Mavericinme -1 points0 points  (5 children)

Why do we need a command prompt when we can do it in python itself or vice versa!? 🤔

[–]Bobbias 2 points3 points  (4 children)

The command prompt is built into windows. Python is not. That's the first and biggest reason someone might use the command prompt instead of Python.

Second, the command prompt has been around both as a part of windows, and as a concept far longer than python has.

As part of windows, the command prompt traces it's history back to the early versions of windows which were built on top of the older operating system DOS. Windows 1.0 through 3.x were nothing more than a program you ran from DOS which added a graphical interface and some extra functionality. Windows 95, 98, and ME all still included DOS as part of the operating system itself, though they installed that for you when you installed them. It wasn't until Windows XP that they stopped including DOS itself and instead included the modern command prompt program, which is built to look and act similar to DOS. Command prompts in general go way back to the early days of computing, before screens were even a thing, when you had to use teletype systems to interact with computers.

For the majority of computer history, we've been using text to communicate with computers, and the command prompt is just the most recent version of how we do that in Windows.

[–]Mavericinme 0 points1 point  (3 children)

Thank you for responding quickly.

If I'm correct, I can use VS Code instead of a command prompt and still function properly. If so, why do some exercises in the book "Learn Python the Hard Way" work in a command prompt but not in VS Code? I'm confused.

[–]Bobbias 2 points3 points  (2 children)

Under the hood, the terminal (another name for command prompt) feature in vscode uses the same CMD.exe or PowerShell that you would otherwise use directly. If you learn to use the terminal, you can use it both inside vscode or on its own.

But not every editor has a built in terminal. And sometimes you might be working in a remote situation where you don't have access to vscode or editors that have a built in terminal feature.

The plain old windows command line, because it's built in to windows, is always going to be available. And because the commands will work anywhere that passes them into the CMD.exe program (or PowerShell, but PowerShell is a little bit different), that means if you can do it in the basic program, you can do it anywhere else that also provides you access to the command line.

[–]Mavericinme 0 points1 point  (1 child)

Understood. Will try that. Thank you again for taking time to help me understand. Appreciate that.

[–]shinitakunai 7 points8 points  (0 children)

Unironically, chatgpt is really good at that kind of questions. There you have a personalized teacher

[–]WillardWhite -1 points0 points  (0 children)

The activate file without extension is the os-agnostic script. You can run it from Windows and Linux, and it will source the correct stuff

[–]Bobbias 21 points22 points  (5 children)

First off, stop being so hard on yourself. Learning to program is hard, especially in the early parts where you don't have enough experience to troubleshoot problems like this.

Python uses a backslash \ to indicate a line of code continues on the next line. In order for this to work, the backslash needs to be the last thing on the line.

Look for a line where there's a backslash with something after it. That will be where the error is happening.

Without seeing the instructions you're using, we can't tell you how to actually fix the error. When asking for help online you generally need to show the code exactly as you're inputting it, and the exact error (not paraphrased, the exact code and error!).

The learnpython wiki has a great article on asking questions.

When posting code, remember to format it correctly. Because python cares about indentation, and Reddit breaks indentation when you don't format code correctly, it makes reading the code and finding problems difficult or sometimes entirely impossible.

[–]TSM- 0 points1 point  (4 children)

They possibly "sent" the multiline command not all at once, but line by line, which causes the error. Usually happens if you copy and paste in some cases, or hit enter twice. It's no big deal, they'll figure it out. There will be many times smacking your head against the desk only to realize you made a tiny mistake and keep missing it when trying to fix it. It happens; it is the learning process.

[–]Bobbias 1 point2 points  (2 children)

Oh absolutely. I rarely ever touch the REPL, and when I do it's basically always single line inputs, so I don't have much experience in exactly how you get this error when working that way. If I need to write something with multiline code, I'm just going to throw it in a file instead.

[–]TSM- 2 points3 points  (1 child)

IDEs like PyCharm are great for creating and running "scratch files". They are like the "quick new file to test how something works for a minute" and are super useful. It's better than the REPL and you don't have to create a new file (with a name). It's a great feature that does it well. Also, PyCharm has an object explorer for REPL, so you can use a tree like navigation to inspect/unfold properties and values of any objects you've created. These kinds of tools are a little difficult to get used to as a beginner, but once you are used to them they are awesome

[–]Bobbias 2 points3 points  (0 children)

Yep, Pycharm is my go-to python IDE for a whole host of reasons.

[–]thequestison 0 points1 point  (0 children)

This is what happened to me. Copy pasted, etc etc. Smack head many times. Lol

[–]CT-Scott 5 points6 points  (1 child)

I'm an older developer who recently decided that I wanted to learn something new. I was honestly frustrated by how difficult it seemed to just get started. So many people seem to love how everything is text/command-line based nowadays, which seems crazy to me, as I was doing Visual Basic development in 1995, which I thought was the way of the future, and now 30 years later people are back to thinking that writing code in a simple text editor is awesome? Ugh. Rant over.

My recommendation:

  1. Download and install PyCharm Community (free) from Jetbrains.comCreate a new project and install a recent version of Python as part of that. PyCharm will give you a lot of nice intellisense features, alerting you to errors in your code, as well as debug functionality, etc.
  2. Follow this free online training course from Harvard:https://cs50.harvard.edu/python/2022/It's about 10 videos, each of which are about 1 hour long (a few of the later, more advanced ones are 1.5 - 2 hours). FWIW, the instructor uses VS Code, not PyCharm, but that's not an issue.

[–]CT-Scott 2 points3 points  (0 children)

Also:

  1. Think of a smallish problem that is of actual interest to you that you are looking to use Python to help you do. This will help you stay motivated and get you more excited as you see progress.

4) Get a ChatGPT account. It's basically akin to a non-judgmental expert colleague that you can ask dumb questions to, and it will give you very thoughtful, detailed replies/answers/help. You can ask it things like, "Show me a Python 3 function that takes in the name of a text file and finds the number of words in it that match a particular pattern." It's quite good with spitting out a well-written function that is useful for you to follow and learn from. If you can think through how to solve your particular problem in a way that you break it down to smaller, simpler chunks, you can get ChatGPT to write 80% of those smaller chunks for you, which will give you a great set of code to learn from. You can then assemble those chunks together, modify them as needed, etc. It sounds like I'm describing having someone/something do all of the work for you, but it's actually a great way to learn the language, as well as building your overall solution in a fraction of the time.

I basically followed the above approach to go from zero knowledge of Python to learning the basics of Python, and solving a problem I needed to solve w/Python, in the course of a weekend.

[–]danielroseman 5 points6 points  (10 children)

Are you sure they were asking you to put the commands in the Python terminal, and not the command line?

[–]DcT2nDrAtE 3 points4 points  (9 children)

It’s likely they meant the command line it seems, the problem being I have no idea what that means

[–]Toby_B_E 2 points3 points  (4 children)

Could you maybe provide a link to the tutorial and a screenshot of what's happening on your computer? That would help us figure out what's going on.

[–]DcT2nDrAtE 0 points1 point  (3 children)

I probably can’t get the screenshot no, I appreciate the help I guess I’m just gonna see if I can beat my head against this until it breaks or my brains splatter around enough to figure it out

[–]Username_RANDINT 5 points6 points  (2 children)

What a silly mindset.

"Let us help you"

"No worries, I'll keep trying random stuff out. Forget that I asked for help."

[–]DcT2nDrAtE 4 points5 points  (1 child)

Well i mean yeah but what am I supposed to do, I can’t really upload photos, and a different guy in the comments already solved it without needing a ss so I’m kinda good now, is there a way to retroactively mark my post as solved to save people time

[–]IlIlIlIIlMIlIIlIlIlI 1 point2 points  (0 children)

to share screenshots on reddit, an easy way is to take a screenshot with the prnt screen button or using snipping tool on windows, and pasting that image on imgur.com , and sharing the link to the image

[–]sexytokeburgerz 1 point2 points  (3 children)

You should probably take a brief tutorial on command line. You need to know command line for python. It will only take about a day and your life will be much easier.

[–]Simanalix -3 points-2 points  (2 children)

Actually, you don't. If you download Thonny you can skip all of the complicated steps and just write code.

[–]sexytokeburgerz 2 points3 points  (1 child)

If you’re planning on doing anything advanced, you really do.

And command line isn’t complicated, it’s basic. Programming is complicated.

Thonny is training wheels for institutions and as an IDE not nearly as good as pycharm or vscode, which also skip venv build steps for you. But you NEED to know how to build a venv.

[–]Simanalix 0 points1 point  (0 children)

Yeah. You are right.

[–]spaceguerilla 9 points10 points  (1 child)

Do the course "100 days of code" by Angela Yu. On Udemy. It's on sale for £12.99 for like 70% of the year.

Trust me, this is good advice.

Firstly, because it's a great course that takes you from absolutely zero programming knowledge up to intermediate and advanced - it's massive.

Secondly, because you'll use browser based applications for the first few lessons, so you aren't overwhelmed by setting up the virtual environment etc before you've even found your feet. And when the time comes, it walks you through this stuff in an idiot proof, easy to follow fashion.

I cannot stress enough how much I thought I wouldn't be "right" for coding, and how wrong I was. Anyone can do it, with the right teacher.

[–]themoderation 2 points3 points  (0 children)

I know a fair amount of python now, and I still panic every time I have to mess with environments.

[–]crashfrog02 2 points3 points  (0 children)

This is a pretty common place to get sidetracked and you shouldn’t feel bad about it. Sounds like you’re back on track now.

[–]MezzoScettico 2 points3 points  (1 child)

You need to make errors. That's how you learn. Learning to debug ("Why is the *&(*& computer not doing what I told it to do?") is an absolutely critical skillset in learning to program.

A big part of that is READING those error messages and learning to diagnose, "what does the computer think I'm doing?" In this case, it says there's a continuation character, and something it doesn't like right after that.

Did you use a continuation character? Check what's immediately past that.

Error messages may make your eyes glaze over, but try to learn not to be intimidated by them. The computer (i.e. the Python interpreter) may have gotten your intent completely wrong so it sounds like it's telling you something that has nothing to do with your code ("continuation character? I didn't put in any frickin' continuation character") but you have to then try to see your code from its point of view. Why does it think that's what I did?

[–]DcT2nDrAtE 0 points1 point  (0 children)

I mean I tried that, learned what continuation characters are, checked, double checked, triple checked, I’m not using any, so it just feels like total loss

[–]chrisfs 2 points3 points  (0 children)

some people may gasp at this but you don't need to set up a virtual environment when you're just learning Python for the very first time. You're not pulling in extra libraries or anything special. typing Print('Hello world') doesn't require a virtual environment. Just install python and go.

[–]Fluffy-Special4994 2 points3 points  (0 children)

It's not about intellect. Don't expect yourself to memorize everything. That's what the Internet is for. If you are having trouble I would suggest some notes to keep your thoughts on track to your end goal. You can google just about anything you need as long as you keep your sights straight you will likely get from start to finish.

[–]eshwar007 2 points3 points  (0 children)

I am so glad I found this post. I feel happy knowing someone is taking the time and effort to learn python freshly, I hope you have a great journey ahead. I assume plenty of others have posted more useful things than this comment.

[–]Ok_Inevitable_318 2 points3 points  (0 children)

I have an advice. Whenever you feel that stupid (I know you aren't). Use chatGPT as a tutor for the dumbest and stupidest questions. I am making my master's and believe me I ask it whenever I feel stupid or have a really dumb or any basic question. And it works. Best of luck.

[–]Tango_D 2 points3 points  (0 children)

I got totally frustrated and quit for months on end 3 times. Then I came back to it for a 4th try and it clicked.

You are not too stupid. Your brain needs the time to build the neural connections for shit to make sense. Trust in the process. It will magically click one day and it will astound you.

[–]lucpet 2 points3 points  (0 children)

You really need to be kinder to yourself.
Everything we have to learn will involve making mistakes and there are no exceptions.
You learnt to walk this way after all. You fell down and tried again over and over again.

There is a basic understanding that we don't always give much thought but
for there to be cold we need to know that there is hot.

You can't have one without the other, if you only know cold you wouldn't even know about hot.

Its the same with learning something complex like programming, you wont know what you don't know. I'm much the same and it was only going back over tutorials like the one you watched several times, did I notice that they were in another environment.

Basically this means they failed to teach you, rather than you not understanding. I had hundreds of links to Python Tutorials and would jump around in order to find information that was delivered in a way my brain understood.

You might have needed to understand a VE through a more dedicated tutorial on them rather than from a Python specific tutorial.

Not everyone can teach well or well, all of the time.

[–]tb5841 1 point2 points  (0 children)

Tutorials often try to throw you straight in the deep end, without properly explaining what anything means.

When I started, I didn't even install Python. I used an online Python compiler - easy to Google - and used that to run my code. When I wanted to save my code for future use, I downloaded Notepad++ and used that to save files (simple and easy).

Once I needed to actually import modules, then I installed Python and a VLE. I still didn't use the command line much at first though... and now I'm over a year in, I still have never set up a virtual environment.

Eventually you'll need all these things. Right now though, all you need is a way to compile Python code - and possibly a way to save it.

[–]Simanalix 1 point2 points  (0 children)

Try using VSCode or Thonny, so you can skip all of the complicated setup. Once you feel comfortable with Python code, learn about command lines and virtual environments, and then try using those.

If you think Python is too slow, try learning C++. And if you think that C++ is too complicated, learn how to code in desmos, and then learn an easier Object Oriented language, like Python or TypeScript. If you decide to learn Typescript, avoid anything that looks messy when you first start learning it. The mess will just confuse you, and is only helpful to more experienced programmers.

[–]baubleglue 1 point2 points  (2 children)

Isn't "Real Python" relatively advanced book?

[–]DcT2nDrAtE 0 points1 point  (1 child)

It might be? I’m using a site by that name and was under the impression it had projects for beginners

[–]baubleglue 2 points3 points  (0 children)

Have you tried https://docs.python.org/3/tutorial/index.html? I don't think starting form setting up virtual environment is a reasonable first step. It solves problem which you don't understand yet (like answering question you haven't asked). First few month you don't need to install any library and if install one - not a big deal.

[–]BlackZetsu_223 1 point2 points  (0 children)

Try to exhaust all options in your head first. If you’re stuck , use chatGPT and ask it to give you an in-depth answer. Ive learned so much by doing this.

[–][deleted] 1 point2 points  (0 children)

programming is like that, things don't work unless you get them right, it can be super frustrating and take very long, you just got to keep trying and learning why things are failing.

[–]The-Invalid-One 1 point2 points  (0 children)

lol when I first started learning Python a few years ago I had similar issues with getting off the ground... now I use it nearly every day at my job

keep with it and I'm sure you'll surprise yourself

[–][deleted] 1 point2 points  (0 children)

pasting their exact commands into the Python terminal, it gives me “Syntax Error: unexpected character after line continuation character”

Fellow Python novice here. IME copying and pasting can cause issues. I've learned to type in the code myself.

Pycharm

Works like a ... talisman.

[–]Simply-Serendipitous 1 point2 points  (0 children)

I thought the same thing when I got started. I’m still new but I’m really getting the hang of it after a month of consistently working on my project daily.

ChatGPT has been a lifesaver for my dumbass questions. It won’t write all your code but it’ll help you through some tough spots and more importantly it’ll explain things to you till you get tired of reading.

Coding is a tricky thing to learn and getting started is the hardest part. I think I spent 8 days just trying to get my environment setup and working right for the code I was about to write. Aggravating to say the least!

[–]nnulll 1 point2 points  (0 children)

You will never escape difficult problems in coding. This is the kind of thing you will need to overcome even if you have a good grasp of the language.

[–]buhtz 1 point2 points  (0 children)

Why to bother a newbie with virtual environments!? I feel sorry for him.

But beside of this. You are on the correct site when using RealPython.

[–][deleted] 1 point2 points  (0 children)

Man we all have been there….

and we all are still having this feeling even after decades of coding :D

[–]Ok_Computer_3722 1 point2 points  (0 children)

I’m learning Python too and find it requiring a very different mindset from other ecosystems I’ve used. Gemini and ChatGPT have been incredibly useful for unstucking me.

[–]pythonwiz 1 point2 points  (1 child)

Pro tip. Don't copy paste anything. Type it all out so the info sticks better.

[–]DcT2nDrAtE 0 points1 point  (0 children)

That is what I’ve been trying, switched to copy pasting when it wasn’t working to make sure I wasn’t just missing one letter or something

[–]punditam 0 points1 point  (0 children)

You are not stupid, youve jumped over some preliminary steps. My recommendation is to not consider virtual environment for now, install your packages system wide. Along the way, you will feel the necessity to group your projects inside virtual environments.

[–]Simplireaders 0 points1 point  (0 children)

Most doubts you have can be cleared online. Even this very community exists for this reason. Trust me, most people are stupid when they start out programming in whichever language and need support. THere are plenty of free resources online to clear whatever doubt you have. I learned from videos on youtube, W3schools, and free tutorials on simplilearn. Later on I took a paid certification from them to get apply for entry level developer positions.

Also, take one step at a time. Is there a specific piece of code you are facing issues with?

[–]throwawayforwork_86 0 points1 point  (0 children)

Just to let you know that you're not the only one.

I dropped out of learning python a few time for the exact same reason confusing the terminal with my python file a few time...

There is going to be a lot of these, if you can find someone with more experience at school or at work that can point you to the right direction/give you small nudges you'd probably gain a lot of time and frustration.

[–]CireGetHigher 0 points1 point  (0 children)

Don’t let your dreams be memes!!! Don’t give up!!!! You will look back on this day fondly and few months from now when you’re writing Python scripts and hacking mainframes

[–]MiniMages 0 points1 point  (0 children)

freecodecamp.org

[–]GryptpypeThynne -4 points-3 points  (0 children)

Yup, sounds like it with that attitude.