Lakshay Kalbhor
Lakshay Kalbhor

Reputation: 617

Python module already installed but getting import error

I have started getting this error for a few modules in python after I 'brew installed python' on my OS X El Capitan. I know that Mac comes with python 2.7 but due to some issues I had to install python explicitly using brew. Now I get this error.

~/Desktop ⌚ 10:57:29
$ python f.py
Traceback (most recent call last):
File "f.py", line 1, in <module>
    import youtube_dl
ImportError: No module named youtube_dl

~/Desktop ⌚ 10:57:30
$ pip install youtube_dl
Requirement already satisfied (use --upgrade to upgrade): youtube_dl in /usr/local/lib/python2.7/site-packages

Upvotes: 1

Views: 2713

Answers (1)

NajlaBioinfo
NajlaBioinfo

Reputation: 579

This error may come from :

  1. The python you run by default isn’t the same that you call by your script : To check this, Please check this command ($ which python) Is this what you put on the top of your script?

  2. Brew doesn’t make symbol link, it’s common issue : Please take a look here(python homebrew by default)

I highly recommend to you virtualenv (https://virtualenv.pypa.io/en/stable/) so you can mange different version of python without altering your OS installation.

Using (pip install youtube_dl) like this, install the package for the current version of python. To be sure, just type ($ pip freeze).

Hope this helps. Good luck :)

Upvotes: 1

Related Questions