0

I am running a Python script from Linux command line, and the script itself, on the first line, import several modules. I got some error message and searched online. Here is a reply from the author of the Python script:

it appears that you are running dexseq_count.py as if it were a shell script, rather than from Python. As a consequence, the first line of the script is interpreted as the Linux command 'import' rather than as Python code, leading to the error you report.

I am curious if the first line of import in Python has been mis-interpretated in Linux, and if so, how can I solve this problem? I have to run in the cmd line instead of in Python.

Thanks so much!

3
  • Are you calling the python interpreter? python dexseq_count.py? or just executing like this ./dexseq_count.py? Commented Jul 1, 2013 at 13:59
  • @HunterMcMillen i use the latter one ;-) Commented Jul 1, 2013 at 14:03
  • 1
    Then you need to follow @Paco advice and make sure you specify the interpreter at the top of your script. Commented Jul 1, 2013 at 14:04

1 Answer 1

6

Two solutions here: You can run the script using python like this: python my_program.py or add this at the top of the file: #!/usr/bin/env python which will switch from bash to python to run this script

Sign up to request clarification or add additional context in comments.

1 Comment

You're welcome. You can now award the answer as it may help other people to know you've found the solution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.