Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python-Instagram API example not working

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.

like image 986
Caveman1515 Avatar asked Oct 09 '14 22:10

Caveman1515


4 Answers

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.

like image 156
anapaulagomes Avatar answered Oct 21 '22 11:10

anapaulagomes


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.

like image 25
ThatAintWorking Avatar answered Oct 21 '22 11:10

ThatAintWorking


The recommended way:

  1. Make sure you have pip installed
  2. Install the package with the command: pip install python-instagram (you may require administrator/sudo privileges for this)

Manual Installation:

  1. Download the zip file from https://github.com/Instagram/python-instagram
  2. Copy the instagram directory to your python's dist-package directory or site-package directory (whatever is relevant to you)

You should then be able to import InstagramAPI with

from instagram.client import InstagramAPI
like image 41
kums Avatar answered Oct 21 '22 10:10

kums


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

like image 27
Alvaro Rodriguez Scelza Avatar answered Oct 21 '22 10:10

Alvaro Rodriguez Scelza