最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Error when trying to import pytube into a project even though pytube is installed - Stack Overflow

programmeradmin4浏览0评论

Using Python 3.13.2 and pytube 15.0.0

When I try to run a program that has from pytube import YouTube I get the following error:

will.air@Mac python % python3 main.py ../test_text_files/tests.txt
Traceback (most recent call last):
File "/Users/will.air/YouTube_Downloader/python/main.py", line 3, in         
<module>
from stats.py import download, downloadMulti, audioOnly, audioMulti,         
getTotalRuntime
File "/Users/will.air/YouTube_Downloader/python/stats.py", line 1, 
in <module>
from pytube import YouTube
ModuleNotFoundError: No module named 'pytube'
will.air@Mac python % pipx install pytube
'pytube' already seems to be installed. Not modifying existing 
installation in '/Users/will.air/.local/pipx/venvs/pytube'. Pass
'--force' to force installation.

I've made sure that pytube is installed and in my Python PATH, but it still isn't working.

Using Python 3.13.2 and pytube 15.0.0

When I try to run a program that has from pytube import YouTube I get the following error:

will.air@Mac python % python3 main.py ../test_text_files/tests.txt
Traceback (most recent call last):
File "/Users/will.air/YouTube_Downloader/python/main.py", line 3, in         
<module>
from stats.py import download, downloadMulti, audioOnly, audioMulti,         
getTotalRuntime
File "/Users/will.air/YouTube_Downloader/python/stats.py", line 1, 
in <module>
from pytube import YouTube
ModuleNotFoundError: No module named 'pytube'
will.air@Mac python % pipx install pytube
'pytube' already seems to be installed. Not modifying existing 
installation in '/Users/will.air/.local/pipx/venvs/pytube'. Pass
'--force' to force installation.

I've made sure that pytube is installed and in my Python PATH, but it still isn't working.

Share Improve this question edited Mar 17 at 20:58 Borne 116 bronze badges asked Mar 16 at 18:08 WillWill 1 3
  • It appears that the pytube module was installed using pipx (i.e. for virtual environments). Try installing the pytube module with pip. pipx is for standalone applications, pip is for importing modules into code. – Man made of meat Commented Mar 17 at 2:52
  • This seems to have worked. I am no longer getting the above error, but my code is throwing errors in different later parts!! This, as far as I'm concerned, is progress! I want to note though, that in order to install with pip on MacOS I had to add the flag --break-system-packages Hopefully that doesn't come back to bite me in the rear! – Will Commented Mar 17 at 23:47
  • I am also on MacOS and I didn't have any issues installing pytube. I used python3 -m pip install pytube. – Man made of meat Commented Mar 18 at 0:44
Add a comment  | 

1 Answer 1

Reset to default 0

Did you try reinstalling 'pytube'? If not, try

Method 1:

pipx uninstall pytube
pipx install pytube

That should work. If not, try

Method 2:

/your_py_file/.venv/lib/python3.13/pytube

If it's not there, install it. Else, delete it and install it using pipx again. This method is kinda dangerous, so use it causticly.

发布评论

评论列表(0)

  1. 暂无评论