0

I need to run this command instagram-scraper "+ username +" --media-metadata --media-types none inside a python executable file as you see bellow is the code I'm using to do that and it's working fine when I run it like that py test.py, but after I turn it to an executable file using the PyInstaller command: pyinstaller -F test.py, it doesn't work and it doesn't return any error, the console disapears directly after execution.

import os

def getFollowers(username):
    os.system("instagram-scraper "+ username +" --media-metadata --media-types none")

getFollowers("oukebdane_med_anis")
8
  • 1. Your function does not return or prints anything. Thus you have no output. 2. The executable is not in the same folder, from where you are running the packaged python program. Commented Aug 1, 2021 at 19:14
  • 3
    Try manually starting a cmd console (command window), and then manually running the executable inside it. This will allow you to see any error messages. The most likely cause is that the instagram-scraper utility isn't in the current directory. Commented Aug 1, 2021 at 19:51
  • instagram-scraper is not a local directory, it's an outside package Commented Aug 1, 2021 at 20:11
  • github.com/arc298/instagram-scraper Commented Aug 1, 2021 at 20:18
  • You install instagram-scraper with pip install instagram-scraper in your Python environment BUT the Python environment used by PyInstaller does have the instagram-scraper executables... Commented Aug 1, 2021 at 20:34

2 Answers 2

2

There's no way PyInstaller can understand os.system("instagram-scraper ...") should also bundle up that instagram-scraper library. You'll need to use it without os.system() for PyInstaller to be able to follow references; something like

import instagram_scraper as isc

def getFollowers(username):
    scraper = isc.InstagramScraper(username=username, media_metadata=True, media_types=[])
    scraper.authenticate_as_guest()
    scraper.scrape()

might work for you...

Sign up to request clarification or add additional context in comments.

3 Comments

I liked the way you tried to solve the problem but after trying your code I didn't get anything (no errors and no outputs)...try it please
I don't much care for trying to circumvent Instagram's terms of use, so I won't. There might be something I'm missing, but you can peek at the library's source to figure out what.
I did it many times I dive as mush as I can but I can't see the lost piece...Help me please
0

After a long struggle, I finally found a solution to the problem, according to the strategy suggested by Mr. @AKX, whom I thank very much.

import instagram_scraper as isc

def getFollowers(username): 
    scraper = isc.InstagramScraper(usernames=[username], media_metadata=True, media_types=['none'])
    scraper.scrape()

getFollowers("oukebdane_med_anis")

NOTE: I tried to edit his answer to adapted to the correct solution but it says 'Suggested edit queue is full'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.