问题
I am looking to use the Python-Instagram package. I have downloaded the package using the script that is provided on https://github.com/Instagram/python-instagram.
I have attempted one of the scripts that is provided. However, I get the same error: ImportError: No module named client
from instagram.client import InstagramAPI
access_token = "YOUR_ACCESS_TOKEN"
api = InstagramAPI(access_token=access_token)
recent_media, next_ = api.user_recent_media(user_id="userid", count=10)
for media in recent_media:
print media.caption.text
What is the module client and how can I install it? I have registered a client with IG.
回答1:
Did you put the name "instagram" on the file? This might be your problem.
After seeing this link, which describes the same error, I realized my mistake.
回答2:
The recommended way:
- Make sure you have pip installed
- Install the package with the command:
pip install python-instagram
(you may require administrator/sudo privileges for this)
Manual Installation:
- Download the zip file from https://github.com/Instagram/python-instagram
- Copy the
instagram
directory to your python'sdist-package
directory orsite-package
directory (whatever is relevant to you)
You should then be able to import InstagramAPI with
from instagram.client import InstagramAPI
回答3:
I just had this same problem and it turned out that I had file named instagram.py in the same package as the file where I was getting this error. So, it was just a name collision. I renamed my local file and everything worked fine.
回答4:
You may end up here like I did, and even by having
from InstagramAPI import InstagramAPI
and everything else correctly set I still got the error:
ImportError: No module named InstagramAPI
I was stupid enough to have InstagramAPI installed in one venv and was using another venv to run my project... dah
来源:https://stackoverflow.com/questions/26288687/python-instagram-api-example-not-working