0

I'm running Ubuntu 18.04.5 LTS
System wide python version is 2.7.17 (obviously), I also have number of virtual environments set up. Today happened something that I don't yet understand, namely:

  • I activated my (3.8) environment

  • Then downloaded a module:

    (3.8) $ pip install algorithms
    
  • Started up idle-python3.8:

    (3.8) $ idle-python3.8 &
    
  • Attempted to import my freshly downloaded module:

    >>> import algorithms
    
  • Then, I saw this error popping up:

    Traceback (most recent call last):
      File "<pyshell#0>", line 1, in <module>
        import algorithms
    ModuleNotFoundError: No module named 'algorithms'
    
  • I closed idle and made sure the module is installed:

    (3.8) $ pip list
    Package                Version
    ---------------------- -------
    algorithms             0.1.4
    astroid                2.4.2
    autopep8               1.5.4
    backcall               0.2.0
    decorator              4.4.2
    ......
    .....
    
  • I had to make sure...:

    (3.8) $ python --version
    Python 3.8.0
    
  • Then I tried this:

    (3.8) $ python3.8
    Python 3.8.0 (default, Oct 28 2019, 16:14:01) 
    [GCC 8.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import algorithms
    >>>
    

What?! How?! Can someone enlighten me please? Thank you.

Suspended
  • 1,184
  • 2
  • 12
  • 28

1 Answers1

2

Idle runs in global environment. You have to start it like this:

python -m idlelib.idle

See detailed answer here: How to launch python Idle from a virtual environment (virtualenv)

Yuri Ginsburg
  • 2,302
  • 2
  • 13
  • 16