Python Shebang not working in Workspaces
After adding the following to
... and running the following in the console of Workspaces:
chmod +x diary.py ./diary.py
... I get the following error:
: No such file or directory
I'm running a local copy of the Python script on my Windows machine with no problems...
Any ideas Kenneth Love?
Jim HoskinsTreehouse Guest Teacher
Hi Iain Simmons
After a bit of head scratching, I think we know what is going on. It looks like the files in your workspace were created in Windows, and uploaded into the workspace. Whatever editor you used was set to use Windows style line endings (AKA "\r\n" or "CRLF"). This causes a problem when trying to run the files on linux, because the shebang line can't have a carriage return (the "\r" or CR in CRLF).
Workspaces itself is maintaining the Windows style line endings of your existing file, but if you create a new file in the workspace, and copy + paste into the new file, that will work.
This is a problem you are likely to encounter if you develop on Windows, and run your code on linux. You want to make sure any editor you use is set to use Unix style line endings.
I hope that helps. If you need help setting up your editor, post what you are using and I'm sure we can find the right settings.
I have the same problem though. I did this lesson on my Windows machine but have only used the workspace and I get the same error message. Luckily the command which Iain posted helped out :-)
Yeah, this impacted me as well and I only used the workspace editor. While I could run the script by passing it to the interpreter directly, I couldn't just "./" it without getting that error message, until after running the sed one-liner.