Can't install?
jamestho opened this issue · 11 comments
Hi,
This looks like a cool piece of code - so, first of all, thank you :)
I'm probably doing something wrong, but I installed python-gedcom as per instructions, ie. pip3 install python-Gedcom
. It shows as being installed correctly. When I use your example code, I receive the following error message:
Traceback (most recent call last):
File "Gedcom.py", line 3, in <module>
from gedcom.element.individual import IndividualElement
File "/home/james/Coding/gedcom/gedcom.py", line 3, in <module>
from gedcom.element.individual import IndividualElement
ModuleNotFoundError: No module named 'gedcom.element'; 'gedcom' is not a package
I also commented out the: '#from gedcom.element.individual import IndividualElement
', to use the strict parser as the source gedcom is an ancestry gedcom 5.5 file, and I receive the same message.
useful stats:
python version 3.7.3
Arch Linux ARM aarch64 (Odroid N2 SBC)
I'm quite new to python programming!
Any thoughts/advice would be gratefully received - thank you!
Hey there :) Could you upload your whole code that triggers this error?
hi :) Thanks for your quick response - all my code is in my repo: https://gitlab.com/thornbej/gedcom-python have a look at gedcom.py
Many thanks!
No problem :) One issue with your code is that you are using the IndividualElement
class but not importing it (since you've commented out the #from gedcom.element.individual import IndividualElement
on line 3
).
https://gitlab.com/thornbej/gedcom-python/blob/master/gedcom.py#L21
The usage of the IndividualElement
class has nothing to do with strict parsing. It's there to allow for extra functionality if the current element is an actual IndividualElement
and not just an Element
.
Strict parsing is described here. :)
I have just uncommented the from gedcom.element.individual import IndividualElement
on line 3, and tried running it again, and I receive the same error message.
[james@minfilia:~/Coding/gedcom]$ python gedcom.py
Traceback (most recent call last):
File "gedcom.py", line 3, in <module>
from gedcom.element.individual import IndividualElement
File "/home/james/Coding/gedcom/gedcom.py", line 3, in <module>
from gedcom.element.individual import IndividualElement
ModuleNotFoundError: No module named 'gedcom.element'; 'gedcom' is not a package
I'll have a look at the Strict Parsing link that you sent to me.
Thanks for your help so far! :)
And it seems you are using the Gedcom.py
file via your terminal? Are you using Virtualenv or the like? I hardly recommend using pyenv to manage Python versions and environments in which you can run and test your code.
Yes, I was running it directly from the CLI! I wasn't running it in virtualenv, but I just installed it, activated my environment, and redownloaded python-gedcom and I continue to receive the same error. my virtualenv is called 'project-gedcom'
(project-gedcom) [james@minfilia:~/Coding/gedcom/project-gedcom]$ python gedcom.py
Traceback (most recent call last):
File "gedcom.py", line 3, in <module>
from gedcom.element.individual import IndividualElement
File "/home/james/Coding/gedcom/project-gedcom/gedcom.py", line 3, in <module>
from gedcom.element.individual import IndividualElement
ModuleNotFoundError: No module named 'gedcom.element'; 'gedcom' is not a package
Should I try pyenv too do you think?
Hmmm seems like it can't find any modules which is weird. Tried installing it too (without pyenv or a Virtualenv) and copied your code and files and ran into the same error. I will have a look on that later this day or week if you're fine with that :)
totally fine with that! There's no immediate rush! Thank you! :)
Would you be able to run help("modules")
in Python. It almost seems like pip is installing it for a different python installation. The result of that command should include "gedcom" somewhere in it.
I know that this is a late response, but I will still post the solution.
Your file is called gedcom.py. When you try to do from gedcom.element.individual import IndividualElement
, Python will first look for a package named gedcom in your project. Since your file is called gedcom.py, Python thinks that is the right package to import. Fix: rename your gedcom.py to main.py or something else. Hope it helps!
@IvicaPizent Thank you! Makes sense.
I just added a "Common problems" section to the README.md
file of the project, describing this problem and how to avoid it.
Closing this issue now.