gpt4 book ai didi

python - 使用 pip 安装 tweepy 模块

转载 作者:行者123 更新时间:2023-12-01 03:33:32 29 4
gpt4 key购买 nike

我对编码相对陌生,但感觉我对基础知识有深入的了解。我希望使用 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'

最佳答案

如上所述,您需要 root 访问权限来存储 pip 包。

Python 3.x:

sudo pip3 install tweepy

Python 2.x:

sudo pip install tweepy

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

git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install

或者您可以使用virtualenv

"What if you can't install packages into the global site-packages directory? For instance, on a shared host.

In all these cases, virtualenv can help you. It creates an environment that has its own installation directories, that doesn't share libraries with other virtualenv environments (and optionally doesn't access the globally installed libraries either)."

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

欲了解更多信息: Installing Python on Mac OS X: virtualenv

关于python - 使用 pip 安装 tweepy 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40590100/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com