Error "No module named 'pytube'"

1

When installing a package using PIP, I can not use it. Example:

pip install pytube 

So far so good, download without problems #

No IDLE:

import pytube 

Result:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import pytube
ImportError: No module named 'pytube'
    
asked by anonymous 02.01.2017 / 17:34

1 answer

1

I believe the problem is caused by multiple pip and python versions installed on the machine.

Go to the terminal and type:

pip --version

The return should be similar to:

pip 8.1.2 from /usr/local/lib/python3.5/site-packages (python 3.5)

Note that at the end of the return, in parentheses, it indicates the version of python. Which in my case is 3.5. So by using the pip command I'll be installing the package in python3.5

You can use a similar command to find out which version of python the python command points to:

python --version

In my case, the answer is:

Python 2.7.11

Now for python3:

$ python3 --version
Python 3.5.1

So, if I install something with the pip, I should run it with the python3 command, which corresponds to the pip version.

You can do the same with the pip2, pip3, python2, python3 commands ... What you should find are the compatible versions of pip with python. The autocomplete of the terminal can help you a lot in this task (type python and press tab several times to see all available, same for pip).

    
02.01.2017 / 17:49