Python Forum
Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1
#1
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..
Reply
#2
one way would be
python_version -m pip install your_package
python3.6 -m pip install pyperclip
Also you may want to consider using virtual environments
Reply
#3
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.
Reply
#4
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
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#5
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/ind...n-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 myenv
then install to your virtualenv after activating
pip3 install pyperclip
but 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
Recommended Tutorials:
Reply
#6
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 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
Reply
#7
Or you could cheat Smile
cd /usr/local/lib/python3.6
sudo rm -rf dist-packages
sudo ln -s /usr/local/lib/python3.5/dist-packages dist-packages
This 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
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  confusion on importing modules carter187 4 342 Mar-03-2024, 08:11 PM
Last Post: snippsat
  How do I organize my simple ftp modules? blobdx7 3 455 Jan-05-2024, 01:23 PM
Last Post: Gribouillis
  Different Ways to Import Modules RockBlok 2 466 Dec-11-2023, 04:29 PM
Last Post: deanhystad
  How can prepare the modules when compiling python3.11? luofeiyu 1 523 Sep-28-2023, 03:50 PM
Last Post: deanhystad
  Help with variable in between modules llxxzz 5 789 Jul-31-2023, 04:20 PM
Last Post: Gribouillis
  What's the best way for multiple modules to handle database activity? SuchUmami 3 611 Jul-08-2023, 05:52 PM
Last Post: deanhystad
  Lost Modules standenman 2 685 Jun-22-2023, 12:18 PM
Last Post: standenman
  Modules GrahamLab 1 795 Apr-13-2023, 09:38 AM
Last Post: snippsat
  How to see the date of installation of python modules. newbieAuggie2019 4 1,466 Mar-31-2023, 12:40 PM
Last Post: newbieAuggie2019
  Import Modules TheBunyip 4 1,177 Mar-10-2023, 04:47 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020