我对编程比较陌生,但我觉得我对基础知识已经有了很好的理解。我希望使用python来尝试使用tweepy模块的twitter,但在命令行中使用pip安装它和其他模块时遇到了问题。
在命令行( macOS Sierra上的终端)中键入pip pip install tweepy将在本文末尾返回错误字符串。
如果有人能解释为什么我不能安装任何模块,我将不胜感激。
提前谢谢。
Collecting tweepy
Using cached tweepy-3.5.0-py2.py3-none-any.whl
Collecting six>=1.7.3 (from tweepy)
Using cached six-1.10.0-py2.py3-none-any.whl
Collecting requests-oauthlib>=0.4.1 (from tweepy)
Using cached requests_oauthlib-0.7.0-py2.py3-none-any.whl
Collecting requests>=2.4.3 (from tweepy)
Using cached requests-2.11.1-py2.py3-none-any.whl
Collecting oauthlib>=0.6.2 (from requests-oauthlib>=0.4.1->tweepy)
Using cached oauthlib-2.0.0.tar.gz
Installing collected packages: six, oauthlib, requests, requests-oauthlib, tweepy
Found existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project (six) 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 six-1.4.1:
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/3m/f0y775rj4nj_xc8t0vntyjk80000gn/T/pip-thDOd4-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'发布于 2016-11-22 00:25:00
如上所述,您需要root访问pip存储包的位置。
Python 3.x:
sudo pip3 install tweepyPython 2.x:
sudo pip install tweepy您也可以使用Git从Github克隆存储库并手动安装:
git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install或者,您可以使用virtualenv
“如果您不能将包安装到全局站点包目录中怎么办?例如,在共享主机上。
在所有这些情况下,virtualenv都可以帮助您。它创建的环境有自己的安装目录,不与其他virtualenv环境共享库(也可以选择不访问全局安装的库)。
基本上,它允许您为每个项目创建一个隔离环境,并帮助您解决权限问题。
欲了解更多信息,请访问:Installing Python on Mac OS X: virtualenv
发布于 2016-11-14 21:55:55
Operation not permitted
您需要运行以下命令:
sudo pip install tweepy发布于 2016-11-14 22:00:19
您的权限有问题。如上所述,您可以尝试使用sudo
https://stackoverflow.com/questions/40590100
复制相似问题