Caveman1515
Caveman1515

Reputation: 81

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.

Upvotes: 6

Views: 16789

Answers (4)

Alvaro Rodriguez Scelza
Alvaro Rodriguez Scelza

Reputation: 4174

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

Upvotes: 2

anapaulagomes
anapaulagomes

Reputation: 334

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.

Upvotes: 10

ThatAintWorking
ThatAintWorking

Reputation: 1360

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.

Upvotes: 3

kums
kums

Reputation: 2701

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

Upvotes: 2

Related Questions