尝试为Python安装Pandas

2024-04-26 05:53:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我似乎无法在我的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'

更新---!!在

  • 我发现我可以下载Python和使用Spyder。在

谢谢你们的帮助!在


Tags: pipinpynumpypandaseggpackagesline
3条回答

试着用sudo
如果你想知道你为什么会遇到这个问题check this stackoverflow answer

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

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

我不同意这样的回答:使用sudo pip install来避免权限错误。这并不总是一个安全的方法。在OSX上,您应该能够使用 user标志绕过当前的错误。在

所以:

pip install user pandas

然而,正如@Kasramvd在评论中指出的,最安全的选择之一是使用虚拟环境。在

不是说使用sudo是不好的,只是说你应该理解你在使用它时在做什么。在

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

When you run pip with sudo, you run setup.py with sudo. In other words, you run arbitrary Python code from the Internet as root. If someone puts up a malicious project on PyPI and you install it, you give an attacker root access to your machine. Prior to some recent fixes to pip and PyPI, an attacker could also run a man in the middle attack to inject their code when you download a trustworthy project.

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

相关问题 更多 >