Interpreter can find a 3rd party module but WIN-R and command line can't
<p>I have installed a 3rd party module named <code>pyperclip</code> to my <code>\python31\Lib\site-packages</code> folder using <code>pip install --target</code> as I also have python 2.7 on the computer and it appears modules are put in 2.7 as a default.</p>

<p>I can run the script below through IDLE just fine. </p>

<pre><code>import pyperclip
import shelve
import sys
import os

curdir = os.getcwd()
mc_shelf = shelve.open(os.path.join(curdir, "mcb2"))

# save clipboard content
if len(sys.argv) == 3 and sys.argv[1].lower() == "save":
    mc_shelf[sys.argv[2]] = pyperclip.paste()
    print("Saved contents of clipboard to keyword \"{}\".".format(sys.argv[2]))
elif len(sys.argv) == 2:
    keyword = sys.argv[1].lower()
    if keyword == "list":
        pyperclip.copy(", ".join(keyword for keyword in mc_shelf))
        print("Copied list to clipboard.")
    elif keyword in mc_shelf:
        pyperclip.copy(mc_shelf[keyword])
        print("Pasted text to clipboard.")
mc_shelf.close()
</code></pre>

<p>However using WIN-R/ the command line I get an ImportError, eg:</p>

<pre><code>PS C:\users\dave\Desktop\2016Coding\AutomateBoring\8-RWFiles&gt; py.exe mcb2.pyw save dave
py.exe : Traceback (most recent call last):
At line:1 char:1
+ py.exe mcb2.pyw save dave
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

  File "mcb2.pyw", line 7, in &lt;module&gt;
    import pyperclip
ImportError: No module named 'pyperclip'
</code></pre>

<p>What exactly might be going on here? Is it something to do with the paths used by each application? I've set environment variables, and set a pythonpath in system variables(this in particular led to a different error) but to be quite honest I'm plain confused.</p>

<p>Attempt at using pip3 to install:</p>

<pre><code>PS C:\&gt; pip install pyperclip
Requirement already satisfied (use --upgrade to upgrade): pyperclip in c:\python27\lib\site-packages

PS C:\&gt; pip3 install pyperclip
pip3 : The term 'pip3' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, 
verify that the path is correct and try again.
At line:1 char:1
+ pip3 install pyperclip
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (pip3:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
</code></pre>

<p>You need to install packages using <code>pip3</code> if you want it to install in your Python3 environment. IE</p>

<pre><code>pip3 install pyperclip
</code></pre>

<blockquote>
  <p>I have installed a 3rd party module named pyperclip to my \python31\Lib\site-packages folder using <code>pip install --target</code></p>
</blockquote>

<p>What you're effectively doing here is using the Python2 version of pip to try to install a Python3 package. Your Python3 environment has its own version of <code>pip</code> -- If your Python3 environment is also in your PATH, you can call pip for Python3 by <code>pip3</code></p>

python module