I just started a new project and the client gave me a new Mac Book Pro along with some Python scripts that they developed. Unfortunately, I cant' seem to get the Python script to run correctly.
I am new to using a Mac.
When I try to run the Python program, I get an error at "import requests" line despite that I have installed the requests module via pip. It may be an issue with I am new to Python and Mac and downloaded the latest Python before I realized that 2.7 is pre-installed or it could be something completely different.
The first 2 lines in the file xxx.py
seem to work
import csv
from bs4 import BeautifulSoup
import requests
Error:
File /Users/ad/Downloads/xxx.py, Line 5, in <module>
from import requests
ImportError: No module named requests
From Terminal:
ADs-MacBook-Pro:Downloads ad$ pip3 list
pip (1.5.6)
requests (2.4.1)
setuptools (2.1)
ADs-MacBook-Pro:Downloads ad$ echo "$PATH"
/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Any suggestion would be appreciated...
By the way, from the downloads folder that I am running the xxx.py
file from I get:
$ python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
...
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named requests
But from the folder that has requests library
ad$ pwd
/Library/Python/2.7/site-packages/requests-2.4.1
I get it to work in TERMINAL
requests-2.4.1 ad$ python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
...
>>> import requests
So I suspect its a PATH or environment variable setup error.