novoid / Memacs

What did I do on February 14th 2007? Visualize your (digital) life in Org-mode
GNU General Public License v3.0
1.03k stars 66 forks source link

Can't get any module to work #89

Closed durableOne closed 5 years ago

durableOne commented 5 years ago

I really love the idea behind this and I wish I could get it to work.

Here's what I have done so far (on ArchLinux and Mac OS, I get the same results):

$ pip3 install memacs # (as recommended in INSTALL.org)

Interestingly, this creates module files in ~/.local/lib/python-3.7/site-packages/memacs/ whose headers say #!/usr/bin/env python2!!

If I clone the repo into my home directory and run (for example):

$ PYTHONPATH=~/Memacs python3 ~/Memacs/bin/memacs_chrome.py -h, I get

ModuleNotFoundError: No module named 'lib'

and if I do

$ PYTHONPATH=~/Memacs:~/Memacs/memacs python3 ~/Memacs/bin/memacs_chrome.py -h

I get the following stack trace:

Traceback (most recent call last): File "/Users/joe/Memacs/bin/memacs_chrome.py", line 5, in from memacs.chrome import Chrome File "/Users/joe/Memacs/memacs/chrome.py", line 13, in from lib.memacs import Memacs File "/Users/joe/Memacs/memacs/lib/memacs.py", line 8, in from .orgwriter import OrgOutputWriter File "/Users/joe/Memacs/memacs/lib/orgwriter.py", line 11, in from .reader import CommonReader File "/Users/joe/Memacs/memacs/lib/reader.py", line 7, in import csv File "/Users/joe/Memacs/memacs/csv.py", line 12, in from .lib.orgformat import OrgFormat ImportError: attempted relative import with no known parent package

I'm sure I'm missing something obvious here and I'd appreciate it if someone can point me in the right direction.

aggi3000 commented 5 years ago

Same problem here, also ArchLinux. But got it to work by converting all relative paths of imports to absolute ones (in memacs/ and memacs/lib) and set PYTHONPATH to the root directory. Maybe that helps someone else, too...

novoid commented 5 years ago

But got it to work by converting all relative paths of imports to absolute ones (in memacs/ and memacs/lib) and set PYTHONPATH to the root directory.

Thanks for this workaround.

However, somebody with better Python-knowledge should assist here in order to get a scalable solution.

aggi3000 commented 5 years ago

However, somebody with better Python-knowledge should assist here in order to get a scalable solution.

I absolutely agree. Just wanted to provide a quick fix for the impatient and unknowing, like me. ;)

Besides that I could only search for answers and came up with PEP 366 (which I don't understand). But I did understand that according to PEP 8 absolute imports are preferred over relatives.

I guess that in one of those PEPs the answer can be found. But it's definitely not me to find it... :(

DerBeutlin commented 5 years ago

I think the issue when installing with pip3 is that the latest release on PyPI is from July 2018, so before the change to python3. It is therefore necessary to release it again.

For the second case everything seem to work fine for all the scripts except the chrome one since there the imports (and a lot of other stuff like the undefined reload function) seems wrong.

Otherwise @aggi3000 is correct, absolute imports are preferred. I will create a PR for that.

novoid commented 5 years ago

It is therefore necessary to release it again.

I tried, but I seem to be in Python hell: twine has some issues due to being too old on my Debian system. So I upgraded it. Now I somehow have the new version as root and the old version as user:

root@sherri ~ # /usr/local/bin/twine --version
twine version 1.15.0 (pkginfo: 1.5.0.1, requests: 2.12.4, setuptools: 33.1.1,
requests-toolbelt: 0.9.1, tqdm: 4.36.1)
root@sherri ~ # 

vk@sherri ~/src/memacs (git)-[master] % /usr/local/bin/twine --version
twine version 1.9.1 (pkginfo: 1.4.1, requests: 2.19.1, setuptools: 40.4.2,
requests-toolbelt: 0.8.0, tqdm: 4.19.5)
vk@sherri ~/src/memacs (git)-[master] %

I'll have to figure out and re-publish as soon as I find the solution.

I already merged the patch, thanks @DerBeutlin! I'll read about the absolute/relative path issue.

Sorry for forgetting to re-publish after the Python3 migration. All my other projects were published afterward but somehow I forgot to do this for my most precious tool: Memacs ;-)

novoid commented 5 years ago

Sorry - I obviously had to learn about virtualenv to overcome version hell with "twine". A new Memacs package is out now: https://pypi.org/project/memacs/2019.10.2.1/

@Joseph-Riad would you be so kind and re-test if the issue is resolved with the latest changes? Thanks for your time!

novoid commented 5 years ago

I assume that https://github.com/novoid/Memacs/pull/91 fixed this issue. If not, please re-open and provide some background so that we can fix it once and for all. Thanks!