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).
Try running your program with python2,
python FILE.py
. Or try to installpip3 install pytube
– Miguel
It’s working now. With IDLE 3.6
– user63295
type "sudo Pip install pytube", if you are using Ubuntu!
– Marcos Vicente Siqueira
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
orpython3 script.py
+pip3
– Leonardo Pessoa