我似乎无法在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'
更新----- !!
感谢帮助人员!
答案 0 :(得分:4)
我不同意使用sudo pip install
来解决权限错误的答案。这并不总是一种安全的方法。在OSX上,您应该能够使用--user
标志来解决当前错误。
所以:
pip install --user pandas
然而,正如@Kasramvd在评论中指出的那样,最安全的选择之一是使用虚拟环境。
并不是说使用sudo
是不好的,只是在使用它时你应该明白自己在做什么。
来自What are the risks of running 'sudo pip'?:
使用sudo运行pip时,使用sudo运行setup.py。换句话说,您以root身份从Internet运行任意Python代码。如果有人在PyPI上设置恶意项目并进行安装,则会授予攻击者root权限以访问您的计算机。在最近对pip和PyPI进行了一些修复之前,攻击者还可以在中间攻击中运行一个人,在你下载一个值得信赖的项目时注入他们的代码。
(答案可能有些过时,但第一部分也适用)
答案 1 :(得分:0)
尝试运行sudo
如果你想知道为什么会出现这个问题check this stackoverflow answer
答案 2 :(得分:-1)
皮普非常不可靠。尝试下载源代码并进行编译。这几乎总是有效。
如上所述。首先尝试使用Sudo。看起来这会阻止你的pip安装尝试。