首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用pip安装tweepy模块

使用pip安装tweepy模块
EN

Stack Overflow用户
提问于 2016-11-14 21:40:08
回答 3查看 5.2K关注 0票数 1

我对编程比较陌生,但我觉得我对基础知识已经有了很好的理解。我希望使用python来尝试使用tweepy模块的twitter,但在命令行中使用pip安装它和其他模块时遇到了问题。

在命令行( macOS Sierra上的终端)中键入pip pip install tweepy将在本文末尾返回错误字符串。

如果有人能解释为什么我不能安装任何模块,我将不胜感激。

提前谢谢。

代码语言:javascript
复制
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'
EN

回答 3

Stack Overflow用户

发布于 2016-11-22 00:25:00

如上所述,您需要root访问pip存储包的位置。

Python 3.x:

代码语言:javascript
复制
sudo pip3 install tweepy

Python 2.x:

代码语言:javascript
复制
sudo pip install tweepy

您也可以使用Git从Github克隆存储库并手动安装:

代码语言:javascript
复制
git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install

或者,您可以使用virtualenv

“如果您不能将包安装到全局站点包目录中怎么办?例如,在共享主机上。

在所有这些情况下,virtualenv都可以帮助您。它创建的环境有自己的安装目录,不与其他virtualenv环境共享库(也可以选择不访问全局安装的库)。

基本上,它允许您为每个项目创建一个隔离环境,并帮助您解决权限问题。

欲了解更多信息,请访问:Installing Python on Mac OS X: virtualenv

票数 2
EN

Stack Overflow用户

发布于 2016-11-14 21:55:55

Operation not permitted

您需要运行以下命令:

代码语言:javascript
复制
sudo pip install tweepy
票数 0
EN

Stack Overflow用户

发布于 2016-11-14 22:00:19

您的权限有问题。如上所述,您可以尝试使用sudo

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40590100

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档