OctavianLee / Barrage

一个开源的b站直播间弹幕助手,主播可以获取直播间内弹幕信息且可以进行发送弹幕功能。
MIT License
50 stars 11 forks source link

[问题]安装遇到Error:ImportError: No module named requests #11

Closed RunzeZ closed 8 years ago

RunzeZ commented 9 years ago

输入代码$: python main.py 反馈如下: Traceback (most recent call last): File "main.py", line 3, in from danmaku.hime import DanmakuHime File "/Users/RunzeZhao/Downloads/Barrage-master/danmaku/hime.py", line 3, in from services.sender import SenderService File "/Users/RunzeZhao/Downloads/Barrage-master/danmaku/services/sender.py", line 5, in import requests ImportError: No module named requests

OctavianLee commented 9 years ago

是这样的如果是mac的话 要 预先用 pip/easy_install 安装 requirements写的 requests里面的库 才能使用。

目前这个库里的获取弹幕功能是可以使用的。

OctavianLee commented 9 years ago

查看README.md里面的说明

RunzeZ commented 9 years ago

哈喽,谢谢回复~ Oh我发现安装环境的时候有error,之前没发现。。。如下:

Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/basecommand.py", line 211, in main status = self.run(options, args) File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/commands/install.py", line 311, in run root=options.root_path, File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_set.py", line 646, in install kwargs File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_install.py", line 803, in install self.move_wheel_files(self.source_dir, root=root) File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_install.py", line 998, in move_wheel_files isolated=self.isolated, File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/wheel.py", line 339, in move_wheel_files clobber(source, lib_dir, True) File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/wheel.py", line 310, in clobber ensure_dir(destdir) File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/utils/init**.py", line 71, in ensure_dir os.makedirs(path) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs mkdir(name, mode) OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/requests’

On Oct 16, 2015, at 12:53 AM, Octavian notifications@github.com wrote:

是这样的如果是mac的话 要 预先用 pip/easy_install 安装 requirements写的 requests里面的库 才能使用。

目前这个库里的获取弹幕功能是可以使用的。

— Reply to this email directly or view it on GitHub https://github.com/OctavianLee/Barrage/issues/11#issuecomment-148642743.

OctavianLee commented 9 years ago

原来我是安装在虚拟环境里面的,如果你实际环境里安装 要加上 sudo

RunzeZ commented 9 years ago

$ sudo pip install -r requirements.txt 如下: The directory '/...XXX.../Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/...XXX.../Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Requirement already satisfied (use --upgrade to upgrade): requests==2.7.0 in /Library/Python/2.7/site-packages (from -r requirements.txt (line 1)) Requirement already satisfied (use --upgrade to upgrade): ujson==1.33 in /Library/Python/2.7/site-packages (from -r requirements.txt (line 2)) Collecting gevent==1.0.2 (from -r requirements.txt (line 3)) Downloading gevent-1.0.2-cp27-none-macosx_10_11_intel.whl (559kB) 100% |████████████████████████████████| 561kB 754kB/s Collecting greenlet==0.4.9 (from -r requirements.txt (line 4)) Downloading greenlet-0.4.9.tar.gz (54kB) 100% |████████████████████████████████| 57kB 5.3MB/s Installing collected packages: greenlet, gevent Running setup.py install for greenlet Complete output from command /usr/bin/python -c "import setuptools, tokenize;file='/private/tmp/pip-build-8WTl8T/greenlet/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-gKHrSU-record/install-record.txt --single-version-externally-managed --compile: running install running build running build_ext building 'greenlet' extension creating build creating build/temp.macosx-10.11-intel-2.7 cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c greenlet.c -o build/temp.macosx-10.11-intel-2.7/greenlet.o creating build/lib.macosx-10.11-intel-2.7 cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.11-intel-2.7/greenlet.o -o build/lib.macosx-10.11-intel-2.7/greenlet.so running install_lib copying build/lib.macosx-10.11-intel-2.7/greenlet.so -> /Library/Python/2.7/site-packages running install_headers creating /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/greenlet error: could not create '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/greenlet': Operation not permitted

----------------------------------------

Command "/usr/bin/python -c "import setuptools, tokenize;file='/private/tmp/pip-build-8WTl8T/greenlet/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-gKHrSU-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-8WTl8T/greenlet

RunzeZ commented 9 years ago

然后按照他说的 $ sudo -H pip install -r requirements.txt 如下: Requirement already satisfied (use --upgrade to upgrade): requests==2.7.0 in /Library/Python/2.7/site-packages (from -r requirements.txt (line 1)) Requirement already satisfied (use --upgrade to upgrade): ujson==1.33 in /Library/Python/2.7/site-packages (from -r requirements.txt (line 2)) Collecting gevent==1.0.2 (from -r requirements.txt (line 3)) Using cached gevent-1.0.2-cp27-none-macosx_10_11_intel.whl Collecting greenlet==0.4.9 (from -r requirements.txt (line 4)) Using cached greenlet-0.4.9.tar.gz Installing collected packages: greenlet, gevent Running setup.py install for greenlet Complete output from command /usr/bin/python -c "import setuptools, tokenize;file='/private/tmp/pip-build-9v3DUP/greenlet/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-fTxQxW-record/install-record.txt --single-version-externally-managed --compile: running install running build running build_ext building 'greenlet' extension creating build creating build/temp.macosx-10.11-intel-2.7 cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c greenlet.c -o build/temp.macosx-10.11-intel-2.7/greenlet.o creating build/lib.macosx-10.11-intel-2.7 cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.11-intel-2.7/greenlet.o -o build/lib.macosx-10.11-intel-2.7/greenlet.so running install_lib copying build/lib.macosx-10.11-intel-2.7/greenlet.so -> /Library/Python/2.7/site-packages running install_headers creating /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/greenlet error: could not create '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/greenlet': Operation not permitted

----------------------------------------

Command "/usr/bin/python -c "import setuptools, tokenize;file='/private/tmp/pip-build-9v3DUP/greenlet/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-fTxQxW-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-9v3DUP/greenlet

OctavianLee commented 9 years ago

这个如果不是了解unix系统的命令操作比较复杂,我还是教你使用虚拟环境吧 这样你能迅速启动。

安装:

sudo pip install vitualenv

启动:

vitualenv 环境名
source 环境名/bin/active

之后你再:

pip install -r requirements.txt

以后每次想用这个程序 只要

source 环境名/bin/active
RunzeZ commented 9 years ago

sudo pip install vitualenv Password: 如下: The directory ‘环境名/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory ‘环境名/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting vitualenv Could not find a version that satisfies the requirement vitualenv (from versions: ) No matching distribution found for vitualenv 嗯似乎是我系统的问题。。。 PS:现在的系统是OS X El Capitan 10.11 (15A284),也许是系统的原因?

On Oct 16, 2015, at 1:16 AM, Octavian notifications@github.com wrote:

的命令操作比较复杂,我还是教你使

OctavianLee commented 9 years ago

virtualenv 不是 是我写错了,我也是这个

RunzeZ commented 9 years ago

把active换成activate后成功了,最后安装完环境后有一行“gevent is in an unsupported or invalid wheel” ;然后就在$ python main.py之后得到了: ImportError: No module named gevent

OctavianLee commented 9 years ago

这个是最新的坑 升级系统后留下的问题,解决方法: pip install cython git+git://github.com/gevent/gevent.git#egg=gevent

参考:http://stackoverflow.com/questions/33009545/gevent-is-in-an-unsupported-or-invalid-wheel

RunzeZ commented 9 years ago

按你提供的方法安装gevent成功了,但是还是在虚拟环境下输入指令pip install -r requirements.txt的时候遇到了这样的Error: $ pip install -r requirements.txt Requirement already satisfied (use --upgrade to upgrade): requests==2.7.0 in ./lib/python2.7/site-packages (from -r requirements.txt (line 1)) Requirement already satisfied (use --upgrade to upgrade): ujson==1.33 in ./lib/python2.7/site-packages (from -r requirements.txt (line 2)) Collecting gevent==1.0.2 (from -r requirements.txt (line 3)) Using cached gevent-1.0.2-cp27-none-macosx_10_11_intel.whl Requirement already satisfied (use --upgrade to upgrade): greenlet==0.4.9 in ./lib/python2.7/site-packages (from -r requirements.txt (line 4)) Installing collected packages: gevent gevent is in an unsupported or invalid wheel

OctavianLee commented 9 years ago

你就可以删掉 这里的 gevent那行了

OctavianLee commented 8 years ago

CFLAGS='-std=c99' pip install gevent==1.0.2

EI caption采用了C101标准编译,但是gevent 1.0.2只能在C99下成功,之后升级gevent到新的正式版本。