Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Import error on pyspark and Zeppelin for local module

avatar
New Member

I am moving to pyspark & zeppelin . I created a two notebook my_settings.py and main.py .

But when I do following in main.py

%pyspark 
import my_settings 

ImportError: No module named my_settings

I get import error saying , no modules found.

This works fine on my local server.

I wonder if there's any env setting for this to work.

1 ACCEPTED SOLUTION

avatar

@bharat sharma Notebooks are not python modules. If you are trying to import a notebook as if it was a python module AFAIK that won't work.

If you are trying to import modules to pyspark application you have different ways to do this. One way is to copy the python file to hdfs and use the following:

%pyspark
sc.addPyFile("/user/zeppelin/my_settings.py")
import my_settings 

HTH

*** If you found this answer addressed your question, please take a moment to login and click the "accept" link on the answer.

View solution in original post

2 REPLIES 2

avatar

@bharat sharma Notebooks are not python modules. If you are trying to import a notebook as if it was a python module AFAIK that won't work.

If you are trying to import modules to pyspark application you have different ways to do this. One way is to copy the python file to hdfs and use the following:

%pyspark
sc.addPyFile("/user/zeppelin/my_settings.py")
import my_settings 

HTH

*** If you found this answer addressed your question, please take a moment to login and click the "accept" link on the answer.

avatar

@bharat sharma If the above answer helped addressed your question, please take a moment to login and click the "accept" link on the answer.