Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using pyspark in standalone scripts #41

Open
kynan opened this issue Jan 1, 2016 · 2 comments
Open

Using pyspark in standalone scripts #41

kynan opened this issue Jan 1, 2016 · 2 comments

Comments

@kynan
Copy link

kynan commented Jan 1, 2016

How can I import pyspark to create a SparkContext in a standalone script?

Running

PYTHONPATH=/usr/local/spark/python python -c 'import pyspark'

fails:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/spark/python/pyspark/__init__.py", line 41, in <module>
    from pyspark.context import SparkContext
  File "/usr/local/spark/python/pyspark/context.py", line 31, in <module>
    from pyspark.java_gateway import launch_gateway
  File "/usr/local/spark/python/pyspark/java_gateway.py", line 31, in <module>
    from py4j.java_gateway import java_import, JavaGateway, GatewayClient
ImportError: No module named py4j.java_gateway

And indeed py4j seems to only exist as a zip file in $SPARK_HOME it is not "installed".

@kynan
Copy link
Author

kynan commented Jan 1, 2016

My current workaround is manually unzipping py4j inside the container:

(
cd $SPARK_HOME/python
unzip lib/py4j-0.8.2.1-src.zip
)

@maxgrenderjones
Copy link

Try using findspark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants