I am trying to use pytube to download videos but it isn't working. I don't know much about python (or any other programming language) so it is likely that my problem is easy to solve. I have tried reading multiple websites and watching several YouTube videos, but I haven't been able to make it work yet.
Requirement already satisfied: pytube3 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (9.6.4)
Requirement already satisfied: typing-extensions in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from pytube3) (3.7.4.3)
My problem: When I open PyCharm, it opens on "main.py". There, I try to write:
import pytube.
But I get the following message:
/Users/applemacosx/PycharmProjects/pythonProject5/venv/bin/python /Users/applemacosx/PycharmProjects/pythonProject5/main.py
Traceback (most recent call last):
File "/Users/applemacosx/PycharmProjects/pythonProject5/main.py", line 1, in <module>
import pytube
ModuleNotFoundError: No module named 'pytube'
Process finished with exit code 1
I have tried searching about this error, but I wasn't able to find anything that I could make work. I would be very grateful if someone could help me understand what I am doing wrong.
What's happening is that you've indeed installed pytube
on the python installation on your machine, but Pycharm creates a virtual environment for each new project you create.
So while pytube
is installed in the python environment on your machine, it's not installed in this newly created python environment. The solution is to install pytube
in the project's virtual environment. There a couple of ways to do that. Probably the easiest would be to go to the terminal window in Pycharm, and execute the pip
install command.