ImportError:没有名为socketserver的模块

时间:2015-05-11 21:44:53

标签: python homebrew

免责声明:noob

我正试图在我的机器上运行streamparse(https://github.com/Parsely/streamparse)并运行。我按照这里的教程:https://youtu.be/ja4Qj9-l6WQ?t=18m50s。我已经安装了leiningen和pip,但在运行命令时

sparse quickstart

我收到错误:

Randalls-MacBook-Pro:streamparse randallbanks$ sparse quickstart
Traceback (most recent call last):
File "/usr/local/bin/sparse", line 9, in <module>
load_entry_point('streamparse==1.1.0', 'console_scripts', 'sparse')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 357, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2394, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2108, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Library/Python/2.7/site-packages/streamparse/__init__.py", line 11, in <module>
import streamparse.cmdln
File "/Library/Python/2.7/site-packages/streamparse/cmdln.py", line 6, in <module>
from .ext.invoke import (list_topologies, kill_topology, run_local_topology,
File "/Library/Python/2.7/site-packages/streamparse/ext/invoke.py", line 25, in <module>
from ..contextmanagers import ssh_tunnel
File "/Library/Python/2.7/site-packages/streamparse/contextmanagers.py", line 8, in <module>
from six.moves.socketserver import UDPServer, TCPServer
ImportError: No module named socketserver

从我所看到的,这似乎是一个问题,名称“socketserver”在python2和python3之间有所不同。我已经尝试下载python3以查看是否可以解决问题,但我一直遇到这个冲突错误:

Randalls-MacBook-Pro:streamparse randallbanks$ sudo brew install python3
Password:
Error: Cowardly refusing to `sudo brew install`
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.

没有'sudo':

Randalls-MacBook-Pro:streamparse randallbanks$ brew install python3
Error: You must `brew link gdbm' before python3 can be installed
Randalls-MacBook-Pro:streamparse randallbanks$ brew link gdbm
Linking /usr/local/Cellar/gdbm/1.11... 
Error: Could not symlink include/gdbm.h
/usr/local/include is not writable.

似乎“不推荐”此错误的解决方法。我尝试从网站https://www.python.org/downloads/mac-osx/手动下载python3,但我真的不知道我在做什么就安装所有这些源文件。我将非常感谢为解决这个问题我应采取的最佳方向提供任何帮助!

2 个答案:

答案 0 :(得分:2)

OS X 10.10附带预先安装的six版本,该版本太旧而无法支持sparse

您最好的选择是创建virtualenv并在其中安装sparse。当你这样做时,将在该virtualenv中安装更新版本的six

请勿尝试升级Apple提供的版本,因为这可能会破坏其他内容。

答案 1 :(得分:0)

问题是你正在使用Python的系统安装,它带有六个版本(1.4.1),这个版本对于streamparse来说太旧了。

在我提出GitHub问题时,我建议大多数人只要使用Anaconda,如果他们在OS X上进行Python开发,以避免尝试升级内容的问题。系统Python安装。