-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

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
daniel Berenson
  • 39
  • 1
  • 1
  • 2

1 Answers1

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.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • 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". – daniel Berenson Aug 07 '16 at 05:34
  • Needs to be the very first line of the file. – Charles Duffy Aug 07 '16 at 05:35
  • Or just run the script as `python `. –  Aug 07 '16 at 05:39
  • 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 import requests ImportError: No module named requests" – daniel Berenson Aug 07 '16 at 05:41
  • Yep, you have to install the libraries that you currently don't have. For example you don't have **requests** and I am guessing some others too. You can google on how to install them. The easiest way is *pip install ...* – billpcs Aug 07 '16 at 05:46
  • thanks. Also, what does this error mean? " line 167 print "Email: ", self.email ^ SyntaxError: Missing parentheses in call to 'print'" – daniel Berenson Aug 07 '16 at 05:53
  • 1
    @danielBerenson, it means you're running code written for Python 2 with Python 3. The languages aren't compatible. – Charles Duffy Aug 07 '16 at 05:57