By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,818 Members | 1,262 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,818 IT Pros & Developers. It's quick & easy.

Running a Python Script via PuTTY

P: 22
I wrote a python script and I have copied my file ( into my http directory. However, when I try to run the script I get many errors...

Expand|Select|Wrap|Line Numbers
  1. ..
  2. : No such file or directoryline 1: #!/usr/bin/python
  3. : command not line 3:
  4. ./ line 4: from: command not found
  5. : command not line 5:
  6. ./ line 6: from: command not found
  7. import: unable to open X server `'.
  8. import: unable to open X server `'.
  9. import: unable to open X server `'.
  10. import: unable to open X server `'.
  11. import: unable to open X server `'.
  12. import: unable to open X server `'.
  13. import: unable to open X server `'.
  14. import: unable to open X server `'.
  15. ./ line 15: from: command not found
  16. import: unable to open X server `'.
  17. : command not line 19:
  18. ./ line 20: syntax error near unexpected token `('
  19. '/ line 20: `today =
  20. ..
I am not sure why I am getting these errors because when I run the script in Python it works fine.

Jul 15 '09 #1
Share this Question
Share on Google+
6 Replies

Expert Mod 2.5K+
P: 2,851
At the command line, did you type in:
python path/
Jul 15 '09 #2

P: 22
Initially, no I did not, I typed ./
However, I just tried that from my http directory which is where the file is located and it said

python: can't open file 'path/': [Errno 2] No such file or directory
Jul 15 '09 #3

Expert Mod 2.5K+
P: 2,851
From your HTTP directory, try typing in python When I posted python path/, I did not mean path literally, but the actual path to your file on your system. You may also need the path to the python interpreter.
Jul 15 '09 #4

P: 22
I wrote my python script in windows, however I need to convert it so that it will run on a linux computer. Do you know how I would convert from windows to linux?
Jul 17 '09 #5

Expert Mod 2.5K+
P: 2,851
Most Python code is not platform dependent. PuTTY is available for Windows and Unix platforms.

Jul 17 '09 #6

P: 1
There are two ways to doing it.
Method 1
First make the script executable
chmod u+x <script>.py

Method 2
Python -v <script>.py
Oct 24 '14 #7

Post your reply

Sign in to post your reply or Sign up for a free account.