你没有pyspark
安装在您正在使用的 python 安装可用的位置。要确认这一点,请在命令行终端上使用virtualenv
激活后,输入您的 REPL (python
)并输入import pyspark
:
$ python
Python 3.5.0 (default, Dec 3 2015, 09:58:14)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyspark
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'pyspark'
如果您看到No module name 'pyspark'
ImportError 你需要安装该库。退出 REPL 并输入:
pip install pyspark
然后重新输入 repl 以确认其有效:
$ python
Python 3.5.0 (default, Dec 3 2015, 09:58:14)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyspark
>>>
请注意,激活虚拟环境至关重要。当位于虚拟环境的目录中时:
$ source bin/activate
这些说明适用于基于 UNIX 的计算机,并且对于 Windows 会有所不同。