Python Forum
pip installs in a different python version and directory than the default 3.11
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pip installs in a different python version and directory than the default 3.11
#1
Hi All,

Quick question - not related explicitly to python code - more related to installing packages.

When I try to install packages with pip install - by default it gets installed to Python 3.10 site-packages location as below, notice the python310 directory.
PS C:\Users\abhik\Nextcloud\Python\Desktop> pip install lxml      
Requirement already satisfied: lxml in c:\users\abhik\appdata\local\programs\python\python310\lib\site-packages (4.9.2)
However my default python version is python 311 and the environment variables have 3.11 paths first in order.
PS C:\Users\abhik\Nextcloud\Python\Desktop> py -V 
Python 3.11.4
[Image: 2023-06-18-11-43-30-Settings.png]

So first question is - why is that happening and how do I change that behavior? I want pip to install packages to 311 directory by default without having to specify the target every time. I thought the PATH variable being defined and set int he right order should achieve that.

Second question is that if I do force the package to be installed in 3.11 by using py -m pip install it does work but even after that when I execute the code with 3.11 as the interpreter it produces an error saying the package is not installed. Code works as intended on 3.10.

PS C:\Users\abhik\Nextcloud\Python\Desktop> py -m pip install lxml     
Requirement already satisfied: lxml in c:\users\abhik\appdata\local\programs\python\python311\lib\site-packages (4.9.2)
I am using VS Code with Jupyter extensions, here is a sample of the error (not full code).
[Image: 2023-06-18-12-24-09-python-automations-p...o-Code.png]

I checked the 3.11 site-packages directory to make sure it is installed and it is. Not sure why the code still won't run on 3.11

All help appreciated.
Thanks in advance.
Reply


Messages In This Thread
pip installs in a different python version and directory than the default 3.11 - by ao_tex_mal - Jun-18-2023, 05:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to find out from outside Python (in Windows) the current version of Python? pstein 5 984 Jun-28-2024, 07:02 AM
Last Post: Samuel34
  run part of a script with a different version of Python jdog 3 714 May-27-2024, 01:57 AM
Last Post: Alice12
  How to resolve version conflicts in Python? taeefnajib 0 1,062 Apr-27-2023, 08:37 PM
Last Post: taeefnajib
  create a default path with idle to a specific directory greybill 0 949 Apr-23-2023, 04:32 AM
Last Post: greybill
  Python venv and PIP version issue JanOlvegg 2 1,476 Feb-22-2023, 02:22 AM
Last Post: JanOlvegg
  Python Version upgrade nitinkukreja 1 1,031 Feb-04-2023, 10:27 PM
Last Post: Larz60+
  Mac default python interpreter Viewpoint8455 2 1,050 Oct-13-2022, 06:25 AM
Last Post: perfringo
  Can't update new python version on Pycharm GOKUUUU 6 4,189 Jul-23-2022, 09:24 PM
Last Post: GOKUUUU
  Building python (3.9.5) with different libexpat version (2.4.6) raghupcr 0 1,429 Feb-25-2022, 11:29 AM
Last Post: raghupcr
  Python keeps running the old version of the code quest 2 4,057 Jan-20-2022, 07:34 AM
Last Post: ThiefOfTime

Forum Jump:

User Panel Messages

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