【问题标题】:Trying to install Pandas for Python尝试为 Python 安装 Pandas
【发布时间】:2018-03-13 20:10:46
【问题描述】:

我似乎无法在我的 Macbook 上安装 Pandas for Python。我经历了不同的线程试图理解但未能找到解决方案。

我用过pip install pandas

我得到的错误:

xxx-MacBook-Pro:~ edss$ pip install pandas
Collecting pandas
  Using cached pandas-0.22.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Requirement already satisfied: python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from pandas)
Collecting numpy>=1.9.0 (from pandas)
  Using cached numpy-1.14.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Requirement already satisfied: pytz>=2011k in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from pandas)
Installing collected packages: numpy, pandas
  Found existing installation: numpy 1.8.0rc1
    DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling numpy-1.8.0rc1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/var/folders/km/5sv3zt816sl74rb9qcmt0vr40000gn/T/pip-LvWuDt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

更新 -----!!

  • 我发现我可以下载 Anaconda 并使用 Spyder。

感谢大家的帮助!

【问题讨论】:

  • 您需要以 root 用户 (sudo pip install pandas) 运行它,或者以更安全的方式将其安装在虚拟环境中。

标签: python pandas numpy error-handling


【解决方案1】:

我不同意使用sudo pip install 来解决权限错误的答案。这并不总是一种安全的方法。在 OSX 上,您应该能够使用 --user 标志绕过当前错误。

所以:

pip install --user pandas

但是,正如 @Kasramvd 在 cmets 中指出的那样,最安全的选择之一是使用虚拟环境。

并不是说使用sudo 不好,只是说你在使用它的时候应该明白你在做什么。

来自What are the risks of running 'sudo pip'?

当你用 sudo 运行 pip 时,你用 sudo 运行 setup.py。换句话说,您以 root 身份从 Internet 运行任意 Python 代码。如果有人在 PyPI 上放置了一个恶意项目并且你安装了它,你就给了攻击者对你机器的 root 访问权限。在最近对 pip 和 PyPI 进行一些修复之前,攻击者还可以在您下载可信项目时运行中间人攻击以注入他们的代码。

(这个答案可能有些过时,但第一部分是正确的)

【讨论】:

    【解决方案2】:

    尝试使用sudo运行
    如果你想知道为什么会出现这个问题check this stackoverflow answer

    【讨论】:

      【解决方案3】:

      Pip 非常不可靠。尝试下载源代码并编译它。这几乎总是有效的。

      如上所述。先用 Sudo 试试。看起来这阻止了您的 pip 安装尝试。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-01-28
        • 2018-09-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-10-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多