2017-06-15 153 views
0

我做了一個點子安裝send2trash的,這是我得到的消息:無法導入模塊sent2trash在Python

Admins-MacBook-Pro-2:~ kylefoley$ 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. 

當我嘗試使用send2trash我得到ModuleNotFoundError:無模塊名爲「send2trash」

也許問題是我正在使用python 3並將其安裝到python 2.7中。我不知道如何安裝send2trash,以便python 3使用它。


更新:

Marekful您好,感謝試圖幫助我。我試過你的建議,但他們沒有工作

Admins-MacBook-Pro-2:~ kylefoley$ 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. 
Admins-MacBook-Pro-2:~ kylefoley$ 

回答

0

構建成功,但安裝失敗,由於權限問題。

OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/send2trash'

sudo運行命令:

Admins-MacBook-Pro-2:~ kylefoley$ sudo pip install send2trash 
+0

看到更新。 (我不知道爲什麼stackoverflow不允許我們做更長的評論) – bobsmith76

+0

這次它成功安裝:'成功安裝send2trash-1.3.0' – marekful

+0

是的,但它仍然無法正常工作。我仍然在Python中遇到同樣的錯誤。 – bobsmith76