Python Forum
Problem installing instaloader
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem installing instaloader
#1
Hello everyone! I am completely new at Python (and programming in general), so please bear with me: I don't know most of the terminology and so on. I would like to ask for help because I am getting desperate. I have been trying to install the instaloader package for several days now, but haven't succeeded and I really need it to work by tomorrow morning.

I dowloaded and installed Python 3.8. I tried to install instaloader in a Jupyter Notebook (Anaconda), but it didn't work: "the Python package manager (pip) can only be used from outside of IPython. Please reissue the pip command in a separate terminal or command prompt". (I work with Windows by the way)
So I opened Python 3.8 itself and typed several variations of "pip install instaloader"/"$ pip install instaloader"/"$ pip3 install instaloader" but NOTHING works. I always get this error: "SyntaxError: invalid syntax".

PLEASE help me? I am sorry to disturb you, but I really don't know what to do anymore. I realise that this probably seems ridiculous to those who have been working with Python for a while, but as I said, I am completely new to this. I would be very grateful for any help!
Reply
#2
from command line (not from python script):
pip3 install instaloader
Reply
#3
@Larz60+
Thank you! It works now!
I have one final connected question. Instaloader also has a Python Module, but it doesn't work when I try to import it in Jupyter Notebooks or in IDLE. Any idea on how I might get this working as well? When I write "import instloader" it responds with: "ModuleNotFoundError: No module named 'instaloader'".
Thank you so much for helping me!
Reply
#4
Quote:but it doesn't work
That doesn't tell me much, please be more specific
Reply
#5
@Larz60+
In Instaloader's Github documentation (https://instaloader.github.io/as-module.html) it says you need to "start with getting an instance of Instaloader" by entering the following code:

"import instaloader

# Get instance
L = instaloader.Instaloader()"

I typed this code into a Jupyter notebook and in an IDLE file. However, when I run the code, I get the following error message:

"---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-bd65c83a9f8a> in <module>
----> 1 import instaloader
2
3 # Get instance
4 L = instaloader.Instaloader()

ModuleNotFoundError: No module named 'instaloader'"

So I don't really know how I can solve this problem. I checked it again and instaloader was installed with pip, so I don't think that's the problem.

Thank you very much for helping me! I really appreciate it!
Reply
#6
please show actual code (within code tags)
and complete, unaltered error tracebacks in error tags
Reply
#7
@Larz60+
I'm sorry, I didn't realise! Thank you for telling me! I added the tags below:

In Instaloader's Github documentation (https://instaloader.github.io/as-module.html) it says you need to "start with getting an instance of Instaloader" by entering the following code:

import instaloader

# Get instance
L = instaloader.Instaloader()
I typed this code into a Jupyter notebook and in an IDLE file. However, when I run the code, I get the following error message:

Error:
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-1-bd65c83a9f8a> in <module> ----> 1 import instaloader 2 3 # Get instance 4 L = instaloader.Instaloader() ModuleNotFoundError: No module named 'instaloader'
So I don't really know how I can solve this problem. I checked it again and instaloader was installed with pip, so I don't think that's the problem.

Thank you very much for helping me! I really appreciate it!
Reply
#8
(Oct-27-2019, 02:17 PM)ledgreve Wrote: I dowloaded and installed Python 3.8. I tried to install instaloader in a Jupyter Notebook (Anaconda), but it didn't work: "the Python package manager (pip) can only be used from outside of IPython. Please reissue the pip command in a separate terminal or command prompt". (I work with Windows by the way)
So I opened Python 3.8 itself and typed several variations of "pip install instaloader"/"$ pip install instaloader"/"$ pip3 install instaloader" but NOTHING works. I always get this error: "SyntaxError: invalid syntax".
I think you get confused here,Anaconda or Python(from python.org) can both work fine together on a OS i guess you use Windows?
You get SyntaxError error because you do this in Python shell,all should be done from command line on OS,eg cmd(Windows).
Remember that theses version standalone,so install instaloader on Anaconda dos not make it work on Python(from python.org) and the other way around.
Have install tutorial here Windows | Anaconda.

So if start with Python(from python.org) which is the main version in Windows path.
# Check Python
E:\div_code
λ python -V
Python 3.7.3

# Check pip
E:\div_code
λ pip -V
pip 19.3.1 from c:\python37\lib\site-packages\pip (python 3.7)

# install
E:\div_code
λ pip install instaloader
Collecting instaloader
  Downloading ....
Successfully installed instaloader-4.2.10

# Test that it work
E:\div_code
λ python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import instaloader

>>> instaloader.__version__
'4.2.10'

>>> L = instaloader.Instaloader()
>>> help(L.download_stories)
Help on method download_stories in module instaloader.instaloader:
download_stories(userids: Union[List[Union[int, instaloader.structures.Profile]] .....

Download available stories from user followees or all stories of users whose ID are given.
Does not mark stories as seen.
To use this, one needs to be logged in
.....

>>> exit()
So now it work on Python(from python.org),but it will not work on Anaconda.
Here i do from Script folder where Anaconda has pip or conda.
# check pip see now that it point to Anaconda folder
G:\Anaconda3\Scripts
λ pip -V
pip 19.0.3 from G:\Anaconda3\lib\site-packages\pip (python 3.7)

G:\Anaconda3\Scripts
λ pip install instaloader
Collecting instaloader .....
Successfully installed instaloader-4.2.10
So if i eg start JupyterLab from Anaconda it will work as i have installed it to Anaconda as shown over.
import sys
import instaloader

print(sys.executable) # Help you see what Python version is used
print(instaloader.__version__)

# Get instance
L = instaloader.Instaloader()

help(L.download_stories)
Output:
G:\Anaconda3\python.exe 4.2.10 Help on method download_stories in module instaloader.instaloader: download_stories(userids: Union[List[Union[int, instaloader.structures.Profile]], NoneType] = None, fast_update: bool = False, filename_target: Union[str, NoneType] = ':stories', storyitem_filter: Union[Callable[[instaloader.structures.StoryItem], bool], NoneType] = None) -> None method of instaloader.instaloader.Instaloader instance Download available stories from user followees or all stories of users whose ID are given. Does not mark stories as seen. To use this, one needs to be logged in :param userids: List of user IDs or Profiles to be processed in terms of downloading their stories :param fast_update: If true, abort when first already-downloaded picture is encountered :param filename_target: Replacement for {target} in dirname_pattern and filename_pattern or None if profile name should be used instead :param storyitem_filter: function(storyitem), which returns True if given StoryItem should be downloaded :raises LoginRequiredException: If called without being logged in.
Reply
#9
Thank you @Snippsat!
I was able to install the pip instaloader package in my Jupyter Notebook by entering following code:

import sys
!{sys.executable} -m pip install instaloader
When I ran the cell I got a confirmation that instaloader had been installed, but I can't get the Instaloader Module to work in Jupyter Notebooks (via Anaconda Navigator).
When I tried to run examples of code they provided themselves to extract Instagram posts, like

L = Instaloader()
for post in L.get_hashtag_posts(urbanphotography):
    L.download_post(post, target='#'+urbanphotography)
(https://instaloader.github.io/as-module....main-class, under "Instagram Structures" - "Posts")

The short text/number to the left of the cell in the notebook simply remained "In [*]" instead of changing to, for example, "In [2]" and nothing happened. Do you know what might be the problem here?

I also tried to run one of their advanced instaloader examples (https://instaloader.github.io/codesnippets.html) in the same Jupyter notebook as a test:

from datetime import datetime
from itertools import dropwhile, takewhile

import instaloader

L = instaloader.Instaloader()

posts = L.get_hashtag_posts('urbanphotography')

SINCE = datetime(2007, 5, 1)
UNTIL = datetime(2007, 3, 1)

for post in takewhile(lambda p: p.date > UNTIL, dropwhile(lambda p: p.date > SINCE, posts)):
    print(post.date)
    L.download_post(post, '#urbanphotography')
But when I ran this code in the cell, I received the following error message:

Error:
C:\Users\XXX\Anaconda\lib\site-packages\win_unicode_console\__init__.py:31: RuntimeWarning: sys.stdin.encoding == '1252', whereas sys.stdout.encoding == 'UTF-8', readline hook consumer may assume they are the same readline_hook.enable(use_pyreadline=use_pyreadline)
Could someone please help me to get it running, so I can extract the json and metadata-txt files I need? I already asked the same question in Instaloader's issue-section several days ago, but so far nobody has replied and I really need to get this working as soon as possible.
Thank you in advance!
Reply
#10
Look at link:
Discussed in issue #121.
There is a example that work.
from datetime import datetime
from itertools import dropwhile, takewhile

import instaloader

L = instaloader.Instaloader()

posts = L.get_hashtag_posts('milfgarden')
# or
# posts = instaloader.Profile.from_username(L.context, PROFILE).get_posts()

SINCE = datetime(2015, 5, 1)
UNTIL = datetime(2015, 3, 1)

for post in takewhile(lambda p: p.date > UNTIL, dropwhile(lambda p: p.date > SINCE, posts)):
    print(post.date)
    L.download_post(post, '#milfgarden')
I do get the same Warning,but it's just a Warning if code works you will get output.
Output:
2015-04-16 09:06:30 2015-04-16 09:06:30 #milfgarden/2015-04-16_09-06-30_UTC.jpg 2015-04-16 09:06:30 #milfgarden/2015-04-16_09-06-30_UTC.jpg [#Baum #klettern #MilfGarden #…] 2015-04-16 09:06:30 #milfgarden/2015-04-16_09-06-30_UTC.jpg [#Baum #klettern #MilfGarden #…] comments 2015-04-16 09:06:30 #milfgarden/2015-04-16_09-06-30_UTC.jpg [#Baum #klettern #MilfGarden #…] comments json 2015-04-16 09:06:30 #milfgarden/2015-04-16_09-06-30_UTC.jpg [#Baum #klettern #MilfGarden #…] comments json 2015-04-08 11:53:02 .....
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Photo Problem installing turtle MasterJediKnight7 17 24,653 Mar-18-2024, 10:22 AM
Last Post: bmohamadyar313
  [WORKED AROUND] Problem installing elitech-datareader, 'cannot import build_py_2to3' NeilUK 4 1,718 Jul-09-2023, 10:01 AM
Last Post: NeilUK
  Problem Installing rasterio gw1500se 1 2,206 Mar-24-2020, 06:28 PM
Last Post: gw1500se
  Problem installing library thunderspeed 2 2,331 Mar-22-2020, 11:04 PM
Last Post: thunderspeed
  Please help: problem installing/importing langdetect module in Jupyter Notebook ledgreve 3 7,300 Dec-30-2019, 08:17 AM
Last Post: LeanbridgeTech
  Problem with installing PyPDF2 Pavel_47 2 6,033 Nov-10-2019, 02:58 PM
Last Post: Pavel_47
  Problem installing numpy and matplotlib achondrite 1 3,132 Jan-16-2019, 11:43 PM
Last Post: snippsat
  Big problem for installing PyCharm sylas 2 3,939 Nov-12-2017, 05:17 PM
Last Post: sylas
  Problem installing urlparse4 package BobLoblaw 2 5,753 Oct-06-2017, 05:16 PM
Last Post: BobLoblaw

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020