Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install sent2trash with pip

Tags:

python-3.x

pip

I tried to install send2trash with pip and got the following error message:

$ pip install send2trash
Collecting send2trash
  Downloading Send2Trash-1.3.0.tar.gz
Building wheels for collected packages: send2trash
  Running setup.py bdist_wheel for send2trash
  Stored in directory: /Users/kylefoley/Library/Caches/pip/wheels/15/76/b3/a81bb5d0bfc6157d1e5df52d34cbea6ffe8a0fc6fea83bddb0
Successfully built send2trash
Installing collected packages: send2trash
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 311, in run
    root=options.root_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 646, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 803, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 339, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 310, in clobber
    ensure_dir(destdir)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 71, in ensure_dir
    os.makedirs(path)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/send2trash'
You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

When I try to import the module i get the following error message:

ModuleNotFoundError: No module named 'send2trash'

Maybe the problem is that I'm using Python 3 and the pip installed it into Python 2.7. I don't know how to install send2trash so that python 3 uses it.

Update:

Hi Marekful, Thanks for trying to help me out. I tried your suggestions but they did not work

$ sudo pip install send2trash
Password:
The directory '/Users/kylefoley/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/kylefoley/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting send2trash
Installing collected packages: send2trash
Successfully installed send2trash-1.3.0
You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Admins-MacBook-Pro-2:~ kylefoley$ sudo -H pip install send2trash
Requirement already satisfied (use --upgrade to upgrade): send2trash in /Library/Python/2.7/site-packages
You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
like image 612
bobsmith76 Avatar asked Sep 10 '25 10:09

bobsmith76


1 Answers

I had the same problem. It was indeed due to the fact that send2trash was downloaded in the python2.7 folder.

(Requirement already up-to-date: pip in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (18.0)). 

I just went into this folder and copied the two folders named send2trash and Send2Trash-1.5.0.dist-info into the similar path corresponding to the python3.7 version:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages

Now it works for me. Hope this helps.

Later edit: To install a module in a certain version of Python on Linux and Mac OS X use the -m switch in the command line:

python2   -m pip install SomePackage  # default Python 2
python2.7 -m pip install SomePackage  # specifically Python 2.7
python3   -m pip install SomePackage  # default Python 3
python3.4 -m pip install SomePackage  # specifically Python 3.4
like image 189
Dana Georgescu Avatar answered Sep 13 '25 04:09

Dana Georgescu