0

I wrote my first program with a non built-in module and it works when I run it in pycharm, but when I try to run it in cmd I get an error: app.py, line 1, in <module> from pytube import YouTube ModuleNotFoundError: No module named 'pytube' I've tried installing pytube module via cmd once again, but the problem still occurs

EDIT: The rest of my scripts are working fine (there are using built-in only modules)

3 Answers3

0

Have you tried installing Pytube with pip on your command prompt? Enter: pip3 install pytube in your terminal and rerun the script. It wasn't clear with the original post if you already did this.

If this doesn't work, try running your script with the -m flag: $ python -m main

A more detailed answer for this issue is already available here.

saurish
  • 68
  • 1
  • 11
  • Yes, I installed pytube with pip command, and unfortunately running script with -m doesn't solve my problem – Ziemowit Kotłowski Jul 31 '20 at 18:39
  • Can you provide any other information? What was the result of the pip command; what was the command you entered with -m; what was the error given when running the script with -m? – saurish Jul 31 '20 at 18:47
  • I've run a command: (rest of the path)\app.py python -m main, and I got a return: ModuleNotFoundError: No module named 'pytube' – Ziemowit Kotłowski Jul 31 '20 at 19:08
  • Could you try (rest of the path)\python -m app – saurish Jul 31 '20 at 22:03
  • Unfortunately, the solution above doesn't work (I get the same error). PS: For now I am looking for a solution better than mine because for now, it's the only one that's working, but I have to wait 2 days until I can mark my answer as the solution. – Ziemowit Kotłowski Jul 31 '20 at 22:20
0

Did you create an environment when you were in pyCharm? There's a chance you have to activate the env when you are in the cmd prompt.

Console without an environment

C:\path>

Activate environment named 'base'

C:\path>activate base

Console with an environment named 'base'

(base) C:\path>
Alec
  • 137
  • 4
0

Ok, so after some research and trying different solutions, I managed to run my script just by copying the missing module to the same directory as my app.py file, I don't know if it's the best solution, but it works.