使用 pip 在 MacOS High Sierra 上安装 s3cmd

使用 pip 在 MacOS High Sierra 上安装 s3cmd

我已经在 MacOS High Sierra 上安装s3cmdpip并且已成功安装。

sudo pip install --user s3cmd
The directory '/Users/crmpicco/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/crmpicco/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 s3cmd
  Downloading https://files.pythonhosted.org/packages/c0/55/ff0ba1d725d3b43c1b116907b4891da0a3b3193e7fa23f75d9fff7a6431e/s3cmd-2.0.1.tar.gz (121kB)
    100% |████████████████████████████████| 122kB 85kB/s 
Requirement already satisfied: python-dateutil in /Library/Python/2.7/site-packages (from s3cmd) (2.6.1)
Requirement already satisfied: python-magic in /Library/Python/2.7/site-packages (from s3cmd) (0.4.15)
Requirement already satisfied: six>=1.5 in /Library/Python/2.7/site-packages (from python-dateutil->s3cmd) (1.11.0)
Installing collected packages: s3cmd
  Running setup.py install for s3cmd ... done
Successfully installed s3cmd-2.0.1

但是,我无法运行它。

s3cmd --configure
-bash: s3cmd: command not found

如果我搜索它,它会显示在/Homebrew目录中:

locate s3cmd
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/s3cmd.rb

我缺少什么来运行它?

答案1

  1. 不要这样做sudo pip install --user。这会破坏您的用户目录 - 您正在以 root 身份安装到您的用户目录,这是潜在问题的根源。使用

    $ sudo pip uninstall -y s3cmd
    $ pip install s3cmd --user
    

    1.1. 由于您已经以 root 身份安装,因此很可能pip缓存目录或文件已被 chown 为 root - 如果出现任何问题,请使用以下命令修复所有权

    $ sudo chown -R crmpicco:staff /Users/crmpicco/
    

    尝试运行s3cmd -h,或者s3cmd --version现在运行,如果成功,您就大功告成了。如果没有成功,请继续阅读。

  2. 现在您已正确安装了软件包,列出安装的文件:

    $ pip show -f s3cmd
    

    找到脚本的路径,它将类似于../../bin/s3cmd,相对于Location目录给出。您需要构建完整bin路径,它应该类似于/Users/crmpicco/Library/Python/X.X/bin

  3. 将构造的bin路径附加到PATH并尝试调用命令:

    $ PATH=$PATH:/full/path/to/bin s3cmd --version
    
  4. 如果上述命令成功,则将bin路径附加到PATH永久:打开~/.bash_profile并添加行

    PATH="/full/path/to/bin:${PATH}"
    export PATH
    

    保存文件并重启终端或运行source ~/.bash_profile以应用更改。现在您应该可以s3cmd随时拨打电话了。

相关内容