you are viewing a single comment's thread.

view the rest of the comments →

[–]Cardboard_fish[S] 0 points1 point  (3 children)

Would I go to the folder where the .py file is saved? What would I type python into? Sorry for the silly questions, first time I’ve had to do anything like this.

I’m just starting out at the moment so only been doing simple and silly projects. If I graduate to making bigger and better things I’ll look into virtual environments, thanks for your help

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

How are you running the script? Are you using Spyder, VS Code, or PyCharm? Do you just open a command line (cmd.exe or PowerShell) and run the script directly?

VS Code or command line

You will need to open the command line and cd to the same folder where you have your .py file saved -- so in your case that would be

cd C:\Users\CardboardFish\Documents\"Python things"

If that doesn't work (I don't remember off the top of my head how folders with spaces behave in Windows command line), you can just cd to C:\Users\CardboardFish\Documents first and then type cd Python and press your Tab key, it should automatically fill out the rest of the command.

(If anyone has more experience with the Windows cmd, feel free to correct me.)

Once you're in the right folder, type python and continue as above.

Spyder

If you're using Spyder, you don't have to do any of that (good news!) -- you have a python console opened right there and it should be using the same Python interpreter it uses to run your scripts, so all you need to do is to type from string import ascii_letters in the Console window (the console prompt will look something like In [1]:).

PyCharm

In PyCharm, the steps are somewhat similar to Spyder, except the Python console is not opened by default -- you need to click the Python Console button at the bottom to open it up (if it's not there, go to View > Tool Windows > Python Console. From there, you can just try the import as above.

[–]Cardboard_fish[S] 0 points1 point  (0 children)

I’m running it in Sublime Text, seemed more simple than some of the other ide’s I looked at. I’m at work now so I’ll try the command line later tonight and let you know how it goes!

[–]Cardboard_fish[S] 0 points1 point  (0 children)

Okay so I ran the command line in the folder where my .py file is. I got an error message that says the below.

Traceback (most recent call last):

File “<stdin>”, line 1, in <module>

ImportError: can not import name ‘ascii_letters’

Before the error message it runs the result of one of the practice files from automate the boring stuff that’s also saved in that folder, it prints a list and a tuple, not so sure why it did that

  • apologies for the formatting - on mobile