python-3.x - 无法使用 pip 安装 sent2trash

标签 python-3.x pip

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

$ 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.

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

ModuleNotFoundError: No module named 'send2trash'

也许问题是我使用的是 Python 3,而 pip 将其安装到了 Python 2.7 中。我不知道如何安装 send2trash 以便 python 3 使用它。

更新:

嗨,Marekful,感谢您尝试帮助我。我尝试了你的建议,但没有用

$ 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.

最佳答案

我也遇到了同样的问题。确实是因为send2trash下载到了python2.7文件夹下。

(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 对应的类似路径中版本:

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

现在它对我有用。希望这会有所帮助。

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

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

关于python-3.x - 无法使用 pip 安装 sent2trash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44556629/

相关文章:

python - 将不同的列加入其中之一 - python

Python:multiprocessing.Queue() 中可能的数据丢失

python - 虚拟环境中的 Pip 升级访问被拒绝

python - 有没有办法用 pip 安装 django 以指向 virtualenv 中的特定版本的 python

python - 在 Heroku 上使用环境变量作为凭证

python-3.x - python : Unable to import TA-lib while it shows in the pip list

python-3.x - 如何有选择地运行 cpython 的回归测试?

python - 构建 python .whl 时排除目录?

pip - Databricks CLI 错误 databricks-connect' 无法识别

python - Roots > Trellis > Ansible 2.4 > 错误!意外异常,这可能是错误 : No module named six