Solution for How to use os.system() inside a python executable file?
is Given Below:
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")
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…
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’