PacktPublishing / Python-Programming-Blueprints

Python Programming Blueprints, published by Packt
MIT License
80 stars 57 forks source link

ModuleNotFoundError: No module named 'weatherterm.parsers.' #6

Closed wardspan closed 6 years ago

wardspan commented 6 years ago

Using the code I pulled down from git I cant get things to run correctly either. (weatherterm) firefly:wardspan[Chapter01]$ python --version Python 3.6.4 (weatherterm) firefly:wardspan[Chapter01]$ python -m weatherterm -u Fahrenheit -a SWXX2372:1:SW -p WeatherComParser -10d Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Users/wardspan/Code/Python-Programming-Blueprints/Chapter01/weatherterm/main.py", line 18, in parsers = parser_loader.load('./weatherterm/parsers') File "/Users/wardspan/Code/Python-Programming-Blueprints/Chapter01/weatherterm/core/parser_loader.py", line 33, in load return _import_parsers(parserfiles) File "/Users/wardspan/Code/Python-Programming-Blueprints/Chapter01/weatherterm/core/parser_loader.py", line 19, in _import_parsers 0) ModuleNotFoundError: No module named 'weatherterm.parsers.'

dfurtado commented 6 years ago

Hi @wardspan

Please, try creating a file called __init__.py inside of the directory weatherterm/parsers. You don't need to add any content to it.

Let me know if that works for you.

wardspan commented 6 years ago

@dfurtado

(weatherterm) firefly:wardspan[parsers]$ touch init.py (weatherterm) firefly:wardspan[parsers]$ ls init.py weather_com_parser.py (weatherterm) firefly:wardspan[Chapter01]$ python3 -m weatherterm -u Fahrenheit -a SWXX2372:1:SW -p WeatherComParser -10d Traceback (most recent call last): File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Users/wardspan/Code/Python-Programming-Blueprints/Chapter01/weatherterm/main.py", line 18, in parsers = parser_loader.load('./weatherterm/parsers') File "/Users/wardspan/Code/Python-Programming-Blueprints/Chapter01/weatherterm/core/parser_loader.py", line 33, in load return _import_parsers(parserfiles) File "/Users/wardspan/Code/Python-Programming-Blueprints/Chapter01/weatherterm/core/parser_loader.py", line 19, in _import_parsers 0) ModuleNotFoundError: No module named 'weatherterm.parsers.'

ghost commented 6 years ago

Hi @wardspan,

As @dfurtado mentioned, you should use $touch __init__.py NOT $touch init.py

Regards

wardspan commented 6 years ago

@armaanreza & @dfurtado That's what I did - please assume for a moment that i somewhat know what I am doing.. Still doesn't work -parser is not recognized in the code. hence the same error - as pasted above

dfurtado commented 6 years ago

Hi @wardspan ,

We are just trying to help you troubleshoot the problem.

So creating the file __init__.py in the weatherterm/parsers directory didn't work, right? Could you please, send me your source code so I can have a closer look? You can zip the entire folder (excluding the phantomJS folder) and mail to pythonblueprints@dfurtado.com

I will be glad to have a look at your code and try to understand what is going wrong.

Best regards

wardspan commented 6 years ago

@dfurtado - understood - trying to figure out where the error is

I am using your code from the git repo - after mine didnt work I always download the authors code to see what I am doing wrong - in this case everything matches and I am still getting the same error when I use your code

dfurtado commented 6 years ago

@wardspan - alright, is your code on the repo https://github.com/wardspan/weatherterm ?

wardspan commented 6 years ago

@dfurtado yes - i am not done but was testing as per your book

dfurtado commented 6 years ago

@wardspan I did a small update on the project. Could you please, pull the changes and see if it solves the problem?

After you pull the changes, make sure you have you this commit:

commit 3d9b1db7384b7b1d1c21e1540cccf5e5aa787b69
Author: Daniel Furtado <daniel@dfurtado.com>
Date:   Wed Mar 21 22:04:30 2018 +0100

    Added missing __init__ file
wardspan commented 6 years ago

thanks @dfurtado the new code seems to be working correctly.