Error "No module named 'pytube'"

Asked

Viewed 599 times

1

When installing a package using PIP I cannot use it. Example:

pip install pytube 

So far so good, down easy#

In the IDLE:

import pytube 

Upshot:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import pytube
ImportError: No module named 'pytube'
  • 2

    Try running your program with python2, python FILE.py. Or try to install pip3 install pytube

  • It’s working now. With IDLE 3.6

  • type "sudo Pip install pytube", if you are using Ubuntu!

  • I find the above option more likely as well. If you already had Python 2 installed and then installed 3, you have to make sure that you are running your script with the same version as pip refers. python script.py + pip or python3 script.py + pip3

1 answer

0


I believe the problem is caused by the existence of multiple versions of Pip and python 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, indicates the version of python. Which in my case is 3.5. Thus, when using the Pip command I will be installing the package in python3.5

You can use a similar command to know which version of python the command is for python points out:

python --version

In my case, the answer is:

Python 2.7.11

As for the python3:

$ python3 --version
Python 3.5.1

So if I install something with Pip, I must run with the command python3, corresponding to the Pip version.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.