首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法使用pip安装sent2trash

无法使用pip安装sent2trash
EN

Stack Overflow用户
提问于 2017-06-15 08:20:41
回答 3查看 1.7K关注 0票数 3

我尝试使用pip安装send2trash,得到以下错误消息:

代码语言:javascript
运行
复制
$ 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.

当我尝试导入模块时,我得到以下错误消息:

代码语言:javascript
运行
复制
ModuleNotFoundError: No module named 'send2trash'

也许问题是我使用的是Python3,pip将它安装到了Python2.7中。我不知道如何安装send2trash才能让Python3使用它。

更新:

嗨,Marekful,谢谢你试着帮我。我试过你的建议,但没有奏效。

代码语言:javascript
运行
复制
$ 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.
EN

回答 3

Stack Overflow用户

发布于 2018-08-24 16:19:43

我也有同样的问题。这确实是因为send2trash是在python2.7文件夹中下载的。

代码语言:javascript
运行
复制
(Requirement already up-to-date: pip in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (18.0)). 

我只是进入这个文件夹,并将名为send2trashSend2Trash-1.5.0.dist-info的两个文件夹复制到与python3.7版本对应的类似路径中:

代码语言:javascript
运行
复制
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages

现在它对我起作用了。希望这能有所帮助。

稍后编辑:要在Linux和Mac上的某个Python版本中安装模块,请在命令行中使用-m开关:

代码语言:javascript
运行
复制
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
票数 3
EN

Stack Overflow用户

发布于 2017-06-15 08:37:52

构建成功,但由于权限问题导致安装失败。

'/Library/Python/2.7/site-packages/send2trash‘:

OSError: Errno 13权限被拒绝

使用sudo运行命令:

代码语言:javascript
运行
复制
Admins-MacBook-Pro-2:~ kylefoley$ sudo pip install send2trash
票数 0
EN

Stack Overflow用户

发布于 2018-09-10 10:12:53

在Python3上使用pip3而不仅仅是pip来运行pip。*首先更新您的包索引:

代码语言:javascript
运行
复制
sudo apt update

如果您尚未在python 3上安装pip,请执行以下操作:

代码语言:javascript
运行
复制
sudo apt install python3-pip

如果您已经在python 3上安装了pip,请更新它:

代码语言:javascript
运行
复制
pip3 install --upgrade pip

然后安装send2trash

代码语言:javascript
运行
复制
pip3 install send2trash
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44556629

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档