Automation – it’s something everyone does, but no one talks about it. Who has the time to engage at this rate on social media? However, these services can be as much as $100 a month! That’s insane, especially for a task that you can set up and automate on your own with a little effort and tinkering. This is probably not going to be super easy for those with absolutely no technical or coding skills. Still, the process is straightforward and step-by-step, and I genuinely believe anyone at any level can get this working. And once you get it working, you’ll feel a thrill of excitement.
One day at my favorite coffee shop, I started to Google search, “How to create an Instagram bot using Python?” I wanted to market my book, and I assumed that targeting specific hashtags for Tokyo would certainly help target potential buyers. And it has helped! Boom.
In all honesty, it wasn’t totally easy for me to figure this out. In fact, it was a frustrating afternoon. I only know basic Python, although I do have some other coding skills. But, it required me to watch a lot of different Youtube videos to parse out bits of the necessary information and then tinker around with the steps provided through GitHub to get this thing running. I first attempted to create this bot using a more complicated way, and it didn’t work. I then put this effort on hold for a few days until I went back to my coffee shop, only to tinker a bit more – until I got login success.
As it turns out, there are two major ways to create an Instagram bot using Python. A common approach is to use the Selenium WebDriver to automate it through your browser. This proved far more complicated than the method I’m going to recommend, and I did not have success with this way.
The second method is quite simple and much more straightforward, and it’s the process that I’ll breakdown below.
Depending on your coding experience, this can take as little as 10 minutes. If you have absolutely no coding experience, it will take longer, but that’s the price you have to pay for a free marketing service that could be significantly helpful. Plus, you’ll feel better about yourself for accomplishing a task millions of people end up desperately paying someone else to do for them.
WARNING: PROCEED WITH CAUTION. AUTOMATING ANYTHING RISKS GETTING YOUR ACCOUNT FLAGGED OR BANNED. CONSULT IG’S RULES ON LIKE/FOLLOW COUNTS PER DAY AND MAKE SURE TO STAY CONSERVATIVE.
What Do You Need to Build a Bot with Python?
Before we get started, you’ll need a few basic things. Again, this is for Mac users.
- The Latest Version of Python 3.7
- GitHub Instabot-py
- A Code Editor – Free or Paid
- Terminal (already on Mac)
A Brief Overview of the Process
Before we get started, here’s a brief summary of the steps required to get this thing running.
First, you’ll download and install the newest version of Python 3.7.
Second, you’ll go to GitHub and download the Instagram bot software onto your desktop.
Third, after you’ve decided on a code editor that’s right for you, you’ll create a .py document (python) by simply copying the code given to you on GitHub, which will be sourced through terminal. This code is really short and filled with parameters for Instagram, such as which hashtags you want to use, and you’ll quite simply need to set specific values to true or false depending on what actions you want the bot to perform. I set follow / unfollow to false since I only want the bot to do liking and commenting.
Fourth, you’ll go into your terminal app (already on your Mac) to install the instabot software from GitHub, then run the Python code saved onto your text editor. If this sounds confusing, don’t worry, it’s not. It’s quite straightforward, but I break it down below. But at least this is generally the process.
1. Download & Install Python 3.7
Macs already come pre-installed with Python, but the version is older. You’ll want to download the newest version of Python 3.7. The code you’ll be using through GitHub requires Python3.6 or higher. The code through which you’ll automate your bot with is written in Python. Python is a programming language that’s typically used for automated tasks. That’s all you need to know. Because your Mac already defaults to a lower version of Python, you’ll need to change the default settings in order to source the new updated version. But, you don’t want to uninstall or remove the pre-installed version on your computer.
This step by step article is helpful on how to change which version of Python is used on your Mac. You’ll need to change a setting in your Python preferences to python3 and then use the command python3 later on in terminal, instead of just python, which is reserved for the older version. The brief article linked will show you precisely what to do.
And if you’re having trouble installing Python, see the video below. It’s really easy.
2. Choose a Code Editor
I’m not a programmer but I do web development so I’m partial to code editors with a nice interface without a lot of superfluous features. I already have a subscription to Setapp which is a cool box of random but useful apps. Inside is a tool called CodeRunner. I love the usability and the interface of CodeRunner. If you don’t have Setapp, you can purchase it for a small price.
Atom is my favorite and it’s free.
Sublime Text is another favorite editor of mine for the same exact reason. It’s free to evaluate but after that you’ll have to pay a pretty hefty price tag.
Visual Studio Code is also free and is the other editor I use. With this editor, you’ll need to quickly install a python extension when prompted.
You might want to experiment with a few different code editors to see which one you like the best but these three are my personal favorites due to simplicity however, Sublime Text is a lot pricier.
3. Go to GitHub
Go to GitHub and access Instabot.py. This is the actual bot. Also listed on this page are useful instructions as well for how to install the bot as well as adjust the parameters. I recommend that you read this page on GitHub. But, the process that I’m going into gives a few more essential details on how to activate terminal than what GitHub provides.
Download and install your Instabot onto your desktop. Click the green download button.
4. Install the Bot through Terminal
Go into your terminal app by simply typing terminal in your search finder. Your screen will most likely be white but you can adjust the preferences if you wish for something easier to visually see. I prefer a black background.
As you can see from GitHub, the install command for the bot is python3 -m pip install instabot-py
However, when you first launch terminal, you will need to write
cd Desktop / (See the image below)
This tells terminal to source the files which are running from your desktop. Once you’ve done this, then go ahead and type the install command as shown below. Magic should happen afterward, however, since mine was already installed, it just gave me a requirement already satisfied.
Syntax and space is very important so be mindful of making sure it’s exact
5. Go to Your Code Editor
Now go into your text editor and open a new document and save it as example.py (or whatever you want.) I saved it as this because that’s what Github did and it just made it simpler.
IMPORTANT: Make sure that this document is saved inside your instabot.py-master folder on your desktop. This is essential.
Now go back to Github and click on your example.py link. This will take you to a url with the text code to copy. Copy all of the code and paste it into your text editor.
Add Your IG Login & Password & Tweak the code
As you can see, my hashtags are specific for Tokyo and Japan, but between these parentheses, you will add your targeted hashtags as well as blacklisted ones.
I changed the follow per day to =0 because I don’t want the bot to follow and unfollow.
Be very careful not to exceed IG regulations of likes and follows per day. this changes periodically so it’s best to be very conservative with this. read more about this on GitHub and the latest instagram policies.
this is a fast way to get your account banned.
Setapp’s code editor screen
Here’s a screenshot of what my code looks like in Setapp. The screen is super clear of a lot of the usual more complicated features in most code editors. Select the Python language and paste your code.
Visual Studio Code’s Interface
Here’s a screenshot of what Visual Studio Code’s interface looks like. At the bottom of Visual Studio Code, you will select the coding language Python. Then save your document and make sure it’s located inside of your instabot.py-master folder on your desktop.
Adjust the comment settings
You’re going to want to adjust the comments. Note that right under comment_list=[ you’ll see three tiers of brackets for constructing a comment starting with mostly demonstratives “this” “the”, etc with a long list of adjectives below. Personally, I NEVER use any of these adjectives so I deleted all of them except for a few that sounded like something I’d actually say. You can amend or delete any word in the parentheses.
But, I did notice that I accidentally screwed up a comma in the syntax. I looked at my comment history to see that my account was commenting “nice pic image.” “Ugh wtf’s a pic image???” I screamed. So yea, just make sure your syntax is good to avoid a bunch of incoherent and nonsensical comments.
Also feel free to delete the bracketed emojis as well.
Now save the document somewhere in the instabot.py-master folder on your desktop.
make sure you are not on your instagram account. if instagram detects duplicate logins from different sources, they will flag your account. so do not engage on instagram on your phone when your bot is running. this might get your account banned.
6. Now Run the Bot
Now this step requires a few lines that are not explicitly stated on GitHub.
Source your desktop via cd Desktop/
Next, type cd instabot.py-master/ (this is just the name of the file on your desktop. Should your file name differ from some reason, then of course use that instead, but it should be the same.)
Since you’ve already installed the bot, this should now work.
The next line, type the command ls and then hit space twice.
Now, you get to call your code stored in your .py document. To do that, type:
python3 example.py and press enter.
Your bot will attempt to login. Most likely, it will require you to enter a special login code because it’s a new login source. Keep trying this until you get login successful. It may take a few tries.
Setting your desktop domain & calling the cd instabot.py-master/
Sourcing Your Instagram Code
Here’s a screenshot of what the python3 example.py code looks like. Hit enter and boom. As stated above, you’ll likely need to enter a security code that’s sent to your phone in order to successfully login. This terminal screen will prompt you if it needs a security code and if so, it will tell you where to enter the code on the terminal screen. Then, you’ll have to re-attempt login until successful. It’s really quite a magical feeling when this happens.
This process worked for me and it should work for you. Of course, nothing technical ever goes right without some tinkering. But, these steps are pretty exact. Also, on GitHub under their Start the Bot section, they list the command python 3 – m instabot_py. This didn’t work for me and the next line gives you the command python3 example.py which did work.
You can keep your bot running all day or night, but just make sure that the parameters are set to a conservative number that won’t get your account banned. But also, take a look at GitHub’s table for their default values of parameters. Their default number of likes per day is 1000 which is pretty standard, but I changed mine to 800 because I’m terrified about getting my account banned. So yea, do this at your own risk.
*** This was republished from a couple of years ago. Since then, some of the links on GitHub have changed, but the bot is still the same. ***