Forums

ImportError: No module named Shares.share_data

Hi guys, I'm hoping someone can help me out with an error that is doing my head in! I am trying to schedule a task however I keep getting a "no module named" error, I am particularly confused as the script runs fine when I run it on my local machine.

The file I am trying to schedule is 'PortfolioStatus.py' and inside this file I am using this import statement: "from Shares.share_data import share_data"

However I am getting the following error:

File "/home/lucasamos/FYP/Shares/Communication/PortfolioStatus.py", line 4, in module 
from Shares.share_data import share_data 
ImportError: No module named Shares.share_data

As you can see in this picture 'Shares.share_data' definitely exists! Am I making a n00b mistake? Thanks!

http://imgur.com/tsU4tRw

It may exist in PyCharm, but if your Python path is not pointing to it, it won't be found. Have a look at this which has a brief primer on how Python finds modules when you try to import them.

Thanks, I have run through all of that, including the "Debugging sys.path issues in web apps" section, it all checks out ok and I can import and run the code from the shell, however I still get the ImportError when I schedule the task

I needed to amend the system path (I thought this was the case), finally worked it out through trial and error and our link. Thanks Glenn

I needed to amend the system path (I thought this was the case), finally worked it out through trial and error and our link. Thanks Glenn

Glad you got it working! Thanks for letting us know.