how do I unscrew messed up pip? Permission denied

69 Views Asked by At

I'm not a python developer and I have wanted to try some LlAMA llm, but I think I have messed up PIP. I'm on Macos, installed python 3.11, but when I do python3.11 -m pip install numpy, I get this error:

ERROR: Exception:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 853, in move
    os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/private/var/folders/_f/zg7ly97n4kl58rn_vnfddfhw0000gn/T/pip-target-ii00g2i_/lib/python/numpy-1.26.4.dist-info' -> '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy-1.26.4.dist-info'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
    status = run_func(*args)
             ^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_internal/cli/req_command.py", line 245, in wrapper
    return func(self, options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_internal/commands/install.py", line 510, in run
    self._handle_target_dir(
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_internal/commands/install.py", line 569, in _handle_target_dir
    shutil.move(os.path.join(lib_dir, item), target_item_dir)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 869, in move
    copytree(src, real_dst, copy_function=copy_function,
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 573, in copytree
    return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 471, in _copytree
    os.makedirs(dst, exist_ok=dirs_exist_ok)
  File "<frozen os>", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy-1.26.4.dist-info'

What feels really wrong is the fact that permission denied library is python 3.10, but I want to use 3.11. Also, when I open visual studio, it sees two interpreters, 3.9 and 3.11.

It is also good to note that I had some problems with different python versions, so I might made a mistake when deleting some of these.

I will appreciate any help, as I'm totally lost, but really wanted to try llama!

1

There are 1 best solutions below

0
SmileMZ On

1st of all I heaviyl advise you to not use global installations for development, otherwise you might screq up your system.

I heavily advise that you create a small virtual environment, which creates a local environment and perform all installations in a local folder.

example: I am in the folder /storage/PyENV/lin and there I create a new environment:

python3.11 -mvenv TestENV

when you look in that directory you have this structure:

drwxr-xr-x 2 tamer tamer 4096 Mar 28 22:26 bin
drwxr-xr-x 3 tamer tamer 4096 Mar 28 22:26 include
drwxr-xr-x 3 tamer tamer 4096 Mar 28 22:26 lib
lrwxrwxrwx 1 tamer tamer    3 Mar 28 22:26 lib64 -> lib
-rw-r--r-- 1 tamer tamer  193 Mar 28 22:26 pyvenv.cfg

Now you enter the environment and can easily make installations in this local folder.

source bin/activate

There you can perform any installation with pip, like this sample installation called "django":

   /storage/PyENV/lin/TestENV  pip install django                                                                                                                                    
 ✔  TestENV  
Collecting django
Downloading Django-5.0.3-py3-none-any.whl.metadata (4.2 kB)
Collecting asgiref<4,>=3.7.0 (from django)
Downloading asgiref-3.8.1-py3-none-any.whl.metadata (9.3 kB)
Collecting sqlparse>=0.3.1 (from django)
Downloading sqlparse-0.4.4-py3-none-any.whl.metadata (4.0 kB)
Downloading Django-5.0.3-py3-none-any.whl (8.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.2/8.2 MB 12.5 MB/s eta 
0:00:00
Downloading asgiref-3.8.1-py3-none-any.whl (23 kB)
Downloading sqlparse-0.4.4-py3-none-any.whl (41 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.2/41.2 kB 1.8 MB/s eta 
0:00:00
Installing collected packages: sqlparse, asgiref, django
Successfully installed asgiref-3.8.1 django-5.0.3 sqlparse-0.4.4

when you look in this folder:

/storage/PyENV/lin/TestENV/lib/python3.11/site-packages

then all the packages are installed in this "virtual env directory" and not global:

   /storage/PyENV/lin/TestENV/lib/python3.11/site-packages  ls -lA                                                                                                                   
 ✔  TestENV  
total 52
drwxr-xr-x  3 tamer tamer 4096 Mar 28 22:29 asgiref
drwxr-xr-x  2 tamer tamer 4096 Mar 28 22:29 asgiref-3.8.1.dist-info
drwxr-xr-x  3 tamer tamer 4096 Mar 28 22:26 _distutils_hack
-rw-r--r--  1 tamer tamer  151 Mar 28 22:26 distutils-precedence.pth
drwxr-xr-x 18 tamer tamer 4096 Mar 28 22:29 django
drwxr-xr-x  2 tamer tamer 4096 Mar 28 22:29 Django-5.0.3.dist-info
drwxr-xr-x  5 tamer tamer 4096 Mar 28 22:26 pip
drwxr-xr-x  2 tamer tamer 4096 Mar 28 22:26 pip-24.0.dist-info
drwxr-xr-x  5 tamer tamer 4096 Mar 28 22:26 pkg_resources
drwxr-xr-x  8 tamer tamer 4096 Mar 28 22:26 setuptools
drwxr-xr-x  2 tamer tamer 4096 Mar 28 22:26 setuptools-65.5.0.dist-info
drwxr-xr-x  5 tamer tamer 4096 Mar 28 22:29 sqlparse
drwxr-xr-x  2 tamer tamer 4096 Mar 28 22:29 sqlparse-0.4.4.dist-info

that ensures that your working environment is local and you don't run in this danger to mess up your system.

And more important, don't do it as an administrator, only as a user.

I hope it helped.