-1

I am a beginner without much knowledge of coding. I am attempting to run the following python script... https://github.com/Sdocquir/moneyonbots/blob/master/shopify3/shopify3.py

When doing so I receive the following message

/Users/xxx/Downloads/moneyonbots-master/shopify3/shopify3.py: line 1: __author__: command not found
/Users/xxx/Downloads/moneyonbots-master/shopify3/shopify3.py: line 3: import: command not found
/Users/xxx/Downloads/moneyonbots-master/shopify3/shopify3.py: line 4: import: command not found
/Users/xxx/Downloads/moneyonbots-master/shopify3/shopify3.py: line 5: import: command not found
/Users/xxx/Downloads/moneyonbots-master/shopify3/shopify3.py: line 6: import: command not found
/Users/xxx/Downloads/moneyonbots-master/shopify3/shopify3.py: line 7: import: command not found
/Users/xxx/Downloads/moneyonbots-master/shopify3/shopify3.py: line 8: import: command not found
from: can't read /var/mail/lxml
from: can't read /var/mail/selenium
from: can't read /var/mail/requests.adapters
/Users/xxx/Downloads/moneyonbots-master/shopify3/shopify3.py: line 15: syntax error near unexpected token `('
/Users/xxx/Downloads/moneyonbots-master/shopify3/shopify3.py: line 15: modes = [('Gift Card', 1), ('Credit Card', 2), ('Paypal', 3)]'

In the beginning of the script it says...

import requests
import sys, traceback
import re
import arrow
import time
import Tkinter as tk
from lxml import html
from selenium import webdriver
from requests.adapters import HTTPAdapter

Do I need to install other libraries to run the script? What are the commands to install these? I am using mac OSX. Thank you.

ENTIRE SCRIPT: https://github.com/Sdocquir/moneyonbots

2
  • Are you sure you have python installed in your system? Commented Aug 7, 2016 at 5:24
  • @ravishankar Yes I have Python 3.5.2 installed Commented Aug 7, 2016 at 5:26

1 Answer 1

12

This happens when your script is being run by a shell, not a Python interpreter at all.

Put a shebang on the first line of the script:

#!/usr/bin/env python

...or, as appropriate,

#!/usr/bin/env python3

...to specify to the operating system that it should be run with a Python interpreter.


You may indeed need to install some 3rd-party packages, but you'll get an error specific to the imports that fail after fixing your interpreter; at that point you can use either the same package manager you used to install Python 3 (if it was installed via MacPorts or Homebrew or similar), or use PyPi, virtualenv, or similar.

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

7 Comments

Thanks for the response. I'm sorry if this is a foolish question but could you please expand on where specifically to put the line "#!/usr/bin/env python".
Needs to be the very first line of the file.
Or just run the script as python <scriptname>.
Ok I added the shebang and ran the script again. I got the following error "Traceback (most recent call last): File "/Users/xxx/Downloads/moneyonbots-master/shopify3/shopify3.py", line 4, in <module> import requests ImportError: No module named requests"
@danielBerenson, it means you're running code written for Python 2 with Python 3. The languages aren't compatible.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.