Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 (/thread-3336.html) |
Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 - bmohanraj91 - May-16-2017 Hi all, In my linux pepper mint system there are three versions of python installed Python 2.7.12 Python 3.5.2 Python 3.6.1 I needed some third party modules in my scripts and I found that I have to use "pip" tool to install the third party modules. I have downloaded pip3 through sudo apt-get install pyhton3-pip I have downloaded pyperclip module through pip3 install pyperclip but Python3.6 unable to find it and throws ModuleNotFoundError. I have explained it in the code below.. mohan@mohn ~ $ python3.6 Python 3.6.1 (default, Apr 22 2017, 20:17:23) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pyperclip Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'pyperclip' >>> [4]+ Stopped python3.6 mohan@mohn ~ $ python3 Python 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pyperclip >>>You could see the import pyperclip code works well in python3 but not in python3.6. How to download modules for the latest version Python 3.6.1.. RE: Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 - buran - May-16-2017 one way would be python_version -m pip install your_package python3.6 -m pip install pyperclipAlso you may want to consider using virtual environments RE: Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 - bmohanraj91 - May-16-2017 Thank you very much, its working now... The command python3.6 -m pip install pyperclip works pretty well, it downloads the module to python3.6 "pip3 install ModuleName" command download the module to python 3.5.2. Is there any way to change the default module download to python 3.6.1 rather than python 3.5.2. RE: Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 - sparkz_alot - May-16-2017 There is a different site-packages directory for each version of Python that you have. If you do pip3 install pyperclip it will only install it in the site-packages for version aliased as python3. If you use pip3.6 install pyperclip , it will install in site-packages for v3.6. This also applies with removing, upgrading and listing modules for the various versions.I don't have the Linux machine running, but it's possible that "pip" and "pip3" will work with both Python 2 and Python 3. EDIT: If you are on a Linux machine I would highly recommend you not mess with the defaults, as Linux, especially the desktop environments use a great deal of Python code. Also, when you install a new version (as in 3.6.1) it is usually in a directory different from the two default versions (usually the"/opt" directory). Another thing to keep in mind, is the "shebang line", with the default versions, it is usually #! /usr/bin/env python or #! /usr/bin/env python3 , with self installed versions, that may change to something like #! /usr/local/bin/python3.6
RE: Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 - metulburr - May-16-2017 I think the intending and proper method is invoking the python interpreter of the version you want as already described https://docs.python.org/3/installing/index.html?highlight=pip#work-with-multiple-versions-of-python-installed-in-parallel But if you are on insisting to use pip3 to link to your 3.6, you could create a virutalenv pip3 -p python3.6 virtualenv myenvthen install to your virtualenv after activating pip3 install pyperclipbut personally i would just use python3.6 -m pip install pyperclip as then its easier to decipher which version of python pip your using when searching packages RE: Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 - bmohanraj91 - May-25-2017 Thanks for your valuable reply, pip3.6 install modules throws pip3.6: command not found error. Also all my python distribution saved in same directory.. mohan@mohn ~ $ which python /usr/bin/python mohan@mohn ~ $ which python3 /usr/bin/python3 mohan@mohn ~ $ which python3.6 /usr/bin/python3.6 (May-16-2017, 01:13 PM)sparkz_alot Wrote: There is a different site-packages directory for each version of Python that you have. If you do RE: Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 - wavic - May-25-2017 Or you could cheat cd /usr/local/lib/python3.6 sudo rm -rf dist-packages sudo ln -s /usr/local/lib/python3.5/dist-packages dist-packagesThis way you create a pointer to /usr/local/lib/python3.5/dist-packages called dist-packages into /usr/local/lib/python3.6/. But this is not the right way to do it since you can use python3.6 pip module directly. As @metulburr noticed |