Search code examples
pythonpython-2.7pipimporterrormoviepy

Installing & running modules in Python 3 (Beginner)


I am very new to the world of coding, so I will try to provide as much information as i can regarding to my question.

Essentially, I wanted to install a module (moviepy) for Python 3. The site were I found the module suggested I use pip to unpack and install the module, so I did.

In my terminal, I entered pip install moviepy and pip proceeded to unpack and install my module, yay!

I then went over to my IDLE to see if the module would import, import moviepy, but received this error:

ImportError: No module named 'moviepy'

Huh? I thought I had just installed moviepy?

Upon further investigation, the module appears to have been written to my Python 2.7 site-packages folder and not my in Python 3 site-packages folder.

So my question is: How can I get my module to install to Python 3?

The modules website says that it is compatible with Python 3.

Im assuming this is a file path issue of some kind, but i don't know where to begin.

I'm currently using a OS X Yosemite version 10.10.2, Python 2.7.6, Python 3.5.0

Any help or comments are greatly appreciated here! Help the n00b!


Solution

  • If you are using python in linux you must run pip with python3:

    python3 -m pip install moviepy
    

    according to python official doc :

    On Linux, Mac OS X and other POSIX systems, use the versioned Python commands in combination with the -m switch to run the appropriate copy of pip:

    python2   -m pip install SomePackage  # default Python 2
    python2.7 -m pip install SomePackage  # specifically Python 2.7
    python3   -m pip install SomePackage  # default Python 3
    python3.4 -m pip install SomePackage  # specifically Python 3.4