Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Using the Console in Python

I am trying to use the Console but every time I type in my file "python string multiply.py" I either get the error "-su: a: command not found" or "python: can't open file 'stringmultiply.py': [Errno 2] No such file or directory" I am using workspaces. Please tell me why this is happening. Thanks

6 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

I haven't seen that happen in my Workspaces. Can you post the code to string_multiply.py?

Yes, thanks!

This part is in stringmultiply.py

input_string = input("What string do you want to use? ")
input_int = input("How many times should I repeat it? ")

print(input_string * int(input_int))

This part is in the console

treehouse:~/workspace$ python stringmultiply.py
python: can't open file 'stringmultiply.py' : [Errno 2] No such file or directory 
treehouse: ~/workspace$
Kenneth Love
Kenneth Love
Treehouse Guest Teacher

This might sound silly but gotta cover all the bases. You did save stringmultiply.py, right?

Yes, I saved it.

Chris Shaw
Chris Shaw
26,676 Points

Hi Robert,

The original command you posted shows a space between string and multiply which won't work, you will either need to add a hyphen or underline between these words.

Seth Weaver
Seth Weaver
1,358 Points

I had a similar problem in Workspaces with the same error:


python: can't open file 'spam.py': [Errno 2] No such file or directory


I hadn't encountered this before, and I had made only one change before this happened. I created a couple folders and moved the files to them.

Removing a file from the folder eliminated the error.

I don't know how to access the file while it is in the folder.

this was happening to me too! create new folder

copy your code

in the new folder> create new file>paste code>save

drag the NEW FILE into the existing folder (not the NEW one)

and it works!