Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
site-packages issue
#1
How to fix this site-packages issue.
I only have one version of Python installed.

[Image: zzWH5R5]

Attached Files

Thumbnail(s)
   
Reply
#2
(Jul-07-2022, 12:35 AM)paulgureghian Wrote: I only have one version of Python installed.
No,it point to two versions.
./.local/lib/python3.10
usr/lib/python3.10
./.local is hidden if just do ls in home/<username> folder.
Do ls -lf to see .local or look in file explorer.
Reply
#3
I do not believe there are two Python's installed. My guess is that the original install was performed as administrator and is shared. If you install a package as a user, you do not have permission to modify the site packages folder, so windows creates a site packages folder under your user\AppData folder.

There are lots of ways you can get around this.
1. Do nothing. This should work fine. Python will look in you AppData for packages first, then in the "global" installation.
2. Make your own Python in your own folder where you have permission to install packages
3. Install the package as administrator.
4. Create a virtual environment that you use for doing your Python work and install the packages in that.

When I first started working with Python I thought about it like a compiler, a tool that let me write programs. It really isn't like that at all. Python is an environment, and you might need multiple, different environments to do your Python work. What I do now is I have a "system" (not really in Windows) Python where I've installed the packages I use for almost everything. When I start working on a new Python "project" I create a virtual environment that has I configure for the work I am going to do, and I always run in that virtual environment.
Axel_Erfurt and snippsat like this post
Reply
#4
(Jul-07-2022, 12:31 PM)deanhystad Wrote: I do not believe there are two Python's installed. My guess is that the original install was performed as administrator and is shared. If you install a package as a user, you do not have permission to modify the site packages folder, so windows creates a site packages folder under your user\AppData folder.
Yes,of course when think of it so is that the reason,i mostly use pyenv then issues like this is none existing.

Addition info to what deanhystad has posted.
If use --user flag it will always use ./.local/lib/python3.10 then avoid permission issues.
python3.10 -m pip install --user hug
As mention make a virtual environment and use that as main version.
Example.
# Make an activate 
tom@tom-VirtualBox:~$ python -m venv new_python
tom@tom-VirtualBox:~$ cd new_python/
tom@tom-VirtualBox:~/new_python$ source bin/activate

# Now python and pip point to this folder
(new_python) tom@tom-VirtualBox:~/new_python$ which python
/home/tom/new_python/bin/python
(new_python) tom@tom-VirtualBox:~/new_python$ which pip
/home/tom/new_python/bin/pip

# Install now will only use this folder
(new_python) tom@tom-VirtualBox:~/new_python$ pip install hug
Collecting hug
  Downloading hug-2.6.1-py2.py3-none-any.whl (75 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 75.1/75.1 KB 1.4 MB/s eta 0:00:00
Collecting falcon==2.0.0
  Downloading falcon-2.0.0-py2.py3-none-any.whl (163 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 164.0/164.0 KB 2.7 MB/s eta 0:00:00
Collecting requests
  Downloading requests-2.28.1-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.8/62.8 KB 2.2 MB/s eta 0:00:00
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.10-py2.py3-none-any.whl (139 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 139.2/139.2 KB 2.5 MB/s eta 0:00:00
Collecting certifi>=2017.4.17
  Downloading certifi-2022.6.15-py3-none-any.whl (160 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 160.2/160.2 KB 13.8 MB/s eta 0:00:00
Collecting idna<4,>=2.5
  Using cached idna-3.3-py3-none-any.whl (61 kB)
Collecting charset-normalizer<3,>=2
  Downloading charset_normalizer-2.1.0-py3-none-any.whl (39 kB)
Installing collected packages: urllib3, idna, falcon, charset-normalizer, certifi, requests, hug
Successfully installed certifi-2022.6.15 charset-normalizer-2.1.0 falcon-2.0.0 hug-2.6.1 idna-3.3 requests-2.28.1 urllib3-1.26.10

# Test
(new_python) tom@tom-VirtualBox:~/new_python$ python
Python 3.10.5 (main, Jun 23 2022, 10:51:05) [GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hug
>>> 
>>> hug.__version__
'2.6.1'
>>> exit()
(new_python) tom@tom-VirtualBox:~/new_python$ 

My tutorial about pyenv Simple Python Version Management
Larz60+ likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Troubleshooting site packages ('h5py' to be specific) aukhare 2 2,006 Nov-02-2020, 03:04 PM
Last Post: snippsat
  site packages, python 3.8 Dixon 12 6,487 Feb-01-2020, 05:32 PM
Last Post: Dixon
  Site packages, Python 3.8 Dixon 2 2,518 Jan-18-2020, 10:42 PM
Last Post: Dixon
  Installing PIP packages issue Renym 2 3,052 Dec-09-2019, 04:44 PM
Last Post: Axel_Erfurt

Forum Jump:

User Panel Messages

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