klieret / verzettler

Non-linear, non-hierarchical knowledge management: Helper scripts for your Zettelkasten.
MIT License
18 stars 1 forks source link

Problems installing in windows #1

Closed Pablo2m closed 3 years ago

Pablo2m commented 3 years ago

Hello, I am trying to install it in windows, I have not succeeded yet, and I need your help with a function but I will tell you about the process in case it works for someone else, at first I thought that everything had worked well, since the installation using "python setup.py install" did not mark any error. But then when running it

PS D:\Zettelkasten\verzettler-master> zk_web
Traceback (most recent call last):
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\Scripts\zk_web-script.py", line 11, in <module>
    load_entry_point('verzettler==0.1.0', 'console_scripts', 'zk_web')()
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources\__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources\__init__.py", line 2862, in load_entry_point
    return ep.load()
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources\__init__.py", line 2462, in load
    return self.resolve()
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources\__init__.py", line 2468, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\verzettler-0.1.0-py3.8.egg\verzettler\bin\zk_web.py", line 9, in <module>
    from verzettler.cli_util import init_zk_from_cli
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\verzettler-0.1.0-py3.8.egg\verzettler\cli_util.py", line 8, in <module>
    import readline
ModuleNotFoundError: No module named 'readline'

This library is not available, fortunately there is a replacement

PS D:\Zettelkasten\verzettler-master> python -m pip install pyreadline
Collecting pyreadline
  Downloading pyreadline-2.1.zip (109 kB)
     |████████████████████████████████| 109 kB 1.1 MB/s
Building wheels for collected packages: pyreadline
  Building wheel for pyreadline (setup.py) ... done
  Created wheel for pyreadline: filename=pyreadline-2.1-py3-none-any.whl size=93844 sha256=9f11d34fbb35bb5fd4c2031fc5ac0ac911012870d85ec5ad22f3e7d18e4498b1
  Stored in directory: c:\users\pablo2m\appdata\local\pip\cache\wheels\0e\6e\9d\402aa64e362e59c7032231a2e6942e647a6c12508d2c77fc4d
Successfully built pyreadline
Installing collected packages: pyreadline
Successfully installed pyreadline-2.1

A second try showed another error

PS D:\Zettelkasten\verzettler-master> zk_web
Traceback (most recent call last):
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\Scripts\zk_web-script.py", line 11, in <module>
    load_entry_point('verzettler==0.1.0', 'console_scripts', 'zk_web')()
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources\__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources\__init__.py", line 2862, in load_entry_point
    return ep.load()
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources\__init__.py", line 2462, in load
    return self.resolve()
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources\__init__.py", line 2468, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\verzettler-0.1.0-py3.8.egg\verzettler\bin\zk_web.py", line 9, in <module>
    from verzettler.cli_util import init_zk_from_cli
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\verzettler-0.1.0-py3.8.egg\verzettler\cli_util.py", line 16, in <module>
    from verzettler.util.paths import get_zk_base_dirs_from_env, pass_fct
ModuleNotFoundError: No module named 'verzettler.util'

Strangely, the two files inside the \ verzettler \ util folder are not copied, that is easily solved Now we come to the problem that I can't solve

PS D:\Zettelkasten\verzettler-master> zk_web -i playground
Traceback (most recent call last):
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\Scripts\zk_web-script.py", line 11, in <module>
    load_entry_point('verzettler==0.1.0', 'console_scripts', 'zk_web')()
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\verzettler-0.1.0-py3.8.egg\verzettler\bin\zk_web.py", line 57, in cli
    output_format_to_converter[args.output.suffix](zk, args.output)
  File "C:\Users\Pablo2m\AppData\Local\Programs\Python\Python38\lib\site-packages\verzettler-0.1.0-py3.8.egg\verzettler\bin\zk_web.py", line 31, in _output_html
    outf.write(format_dot_html(zk.dot_graph()))
AttributeError: 'Zettelkasten' object has no attribute 'dot_graph'

I've been looking everywhere and I can't find that function / attribute ('dot_graph'), am I doing something wrong? Could you help me? Thank you in advance

klieret commented 3 years ago

Hi!

Sorry, I haven't really brought this to a stage where I was expecting others to try and install it.

I haven't used zk_web since quite some time, it's quite likely that I broke this (meanwhile small graphs are included in the webserver view).

Let me see if I can offer a quick fix (but I'm quite busy at the moment unfortunately).

klieret commented 3 years ago

Some of your errors I just solved (but you worked around them already)

klieret commented 3 years ago

Can you install the latest version again?

So zk_web -o out.dot works for me (and then you can use graphviz to turn it into a graph)

Pablo2m commented 3 years ago

Thanks for replying, the setup.py file needs a little fix

E:\Zettelkasten\verzettler-master>python setup.py install
Traceback (most recent call last):
  File "setup.py", line 26, in <module>
    with (this_dir / "README.rst").open() as fh:
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\pathlib.py", line 1218, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\pathlib.py", line 1074, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: 'E:\\Zettelkasten\\verzettler-master\\README.rst'

Ignoring that, the other error I see is that the vis-network.min file is not copied to its destination, in my case

C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\Lib\site-packages\verzettler-0.1.0-py3.8.egg\verzettler\html_resources\vis-network.min.js

Once I copied the zk_web command it worked, it's a nice visualization.

Now I'm seeing what I can do with get_zk_base_dirs_from_env () In order to run zk_server

klieret commented 3 years ago

Thanks for replying, the setup.py file needs a little fix

You're right of course! Forgot to update that

Ignoring that, the other error I see is that the vis-network.min file is not copied to its destination, in my case

Yeah, probably needs to be added to the manifest

Thanks for helping me work out all these issues! It's not thoroughly tested so there's probably a lot to do.

Now I'm seeing what I can do with get_zk_base_dirs_from_env () In order to run zk_server

Ah, right it currently doesn't let you specify the input directories manually...

klieret commented 3 years ago

also you'll need to have pandoc installed to use the server thing

klieret commented 3 years ago

I mean what you could do as a quick workaround is to simply let get_zk_base_dirs_from_env return ["/path/to/my/directory/"] by modifying the source file

klieret commented 3 years ago

The real solution would of course be to copy the quick command line interface also to the server application. I might try to do that in the next few days, but kind of very busy, so let's see

Pablo2m commented 3 years ago

Tonight I'll try to tweak the setup.py. I have made a small detour adding two lines to set ZK_HOME (for some strange reason it does not persist, I will try to investigate that this week). Even with those two things there is still a problem to run it on windows, I guess where the problem is but I have to do some tests in the interactive console to understand if I can solve it or not.

Pablo2m commented 3 years ago

I am trying to understand a small problem, at first I thought it happened only in windows but I have managed to make it happen in ubuntu (using wsl2).

pablo2m@DESKTOP-B8QCU7E:/mnt/c/Users/Bios-PC/verzettler$ zk_server
 * Serving Flask app "verzettler.bin.zk_server" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
DEBUG: Opening 00000000000000
ERROR: Exception on / [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.8/dist-packages/verzettler-0.1.0-py3.8.egg/verzettler/bin/zk_server.py", line 153, in root
    return open(zk.root)
  File "/usr/local/lib/python3.8/dist-packages/verzettler-0.1.0-py3.8.egg/verzettler/bin/zk_server.py", line 143, in open
    converted = pandoc_converter.convert(note)
  File "/usr/local/lib/python3.8/dist-packages/verzettler-0.1.0-py3.8.egg/verzettler/note_converter.py", line 290, in convert
    ret = subprocess.run(
  File "/usr/lib/python3.8/subprocess.py", line 489, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'pandoc'
127.0.0.1 - - [07/Oct/2020 10:52:44] "GET / HTTP/1.1" 500 -
127.0.0.1 - - [07/Oct/2020 10:52:47] "GET /favicon.ico HTTP/1.1" 404 -

and yet it was installed,

pip3 list
Package                Version
pandoc                 1.0.2

Then I discovered (I think you told me some of that) that its necessary to install it from the package manager and not from pip3.

pablo2m@DESKTOP-B8QCU7E:/mnt/c/Users/Bios-PC/verzettler$ zk_server
 * Serving Flask app "verzettler.bin.zk_server" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
DEBUG: Opening 00000000000000
ERROR: Exception on / [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.8/dist-packages/verzettler-0.1.0-py3.8.egg/verzettler/bin/zk_server.py", line 153, in root
    return open(zk.root)
  File "/usr/local/lib/python3.8/dist-packages/verzettler-0.1.0-py3.8.egg/verzettler/bin/zk_server.py", line 145, in open
    return render_template(
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/templating.py", line 138, in render_template
    ctx.app.jinja_env.get_or_select_template(template_name_or_list),
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 869, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 830, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 804, in _load_template
    template = self.loader.load(self, name, globals)
  File "/usr/lib/python3/dist-packages/jinja2/loaders.py", line 113, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/templating.py", line 60, in get_source
    return self._get_source_fast(environment, template)
  File "/usr/local/lib/python3.8/dist-packages/Flask-1.1.2-py3.8.egg/flask/templating.py", line 89, in _get_source_fast
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: page.html

After moving the necessary files, in this case those in the template folder this error is solved, and another appears:

ERROR: Exception on / [GET]
Traceback (most recent call last):
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\flask-1.1.2-py3.8.egg\flask\app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\flask-1.1.2-py3.8.egg\flask\app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\flask-1.1.2-py3.8.egg\flask\app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\flask-1.1.2-py3.8.egg\flask\_compat.py", line 39, in reraise
    raise value
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\flask-1.1.2-py3.8.egg\flask\app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\flask-1.1.2-py3.8.egg\flask\app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\verzettler-0.1.0-py3.8.egg\verzettler\bin\zk_server.py", line 153, in root
    return open(zk.root)
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\verzettler-0.1.0-py3.8.egg\verzettler\zettelkasten.py", line 92, in root
    return _get_root(self._graph)
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\verzettler-0.1.0-py3.8.egg\verzettler\zettelkasten.py", line 77, in _get_root
    return min(g.nodes)
ValueError: min() arg is an empty sequence

And this far I can get, never use networkx and certain things I do not understand. When you have time, could you see it ?. I am using the playground directory for these tests

klieret commented 3 years ago

Hmmm, taking a quick look at this, this is a bug that happens if there are no nodes (notes) found. So here

@lru_cache(maxsize=100)
def _get_root(g: nx.DiGraph) -> str:
    return min(g.nodes)

you have the minimum over an empty sequence.

Of course I could just return None, but I'm not sure what this would break

klieret commented 3 years ago

Okay, I've added some command line things to the zk_server.

So you should now be able to remove the workaround with the environment variables and use

zk_server -l d  -i /path/to/verzettler/verzettler/tests/playground/

And if you click on the link that is shown, you should see this

image

klieret commented 3 years ago

So the bug with having zero notes is annoying, but it shouldn't actually happen if you correctly load from the playground directory. perhaps your workaround didn't work, can you try with the example call that I wrote?

Pablo2m commented 3 years ago

Using the example command it loads correctly, thank you very much.

The zettel display, navigation and search (I'm not so sure about this, I feel like sometimes it behaves like I'm lucky when it isn't) work.

The integration with typora does not work, it seems a problem between windows and typora, I will analyze it.

The copying of the html, js and company files is pending, I will also see if I learn how to do it.

The reload command only reloads the directories in the environment variable, not the one specified on the command line, I think it could fix it

The dashboard is not working for me, this is what I get

[5 2]
[-0.5  0.5  1.5]
defaultdict(<class 'int'>, {'tests': 7})
ERROR: Exception on /dashboard [GET]
Traceback (most recent call last):
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\flask-1.1.2-py3.8.egg\flask\app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\flask-1.1.2-py3.8.egg\flask\app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\flask-1.1.2-py3.8.egg\flask\app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\flask-1.1.2-py3.8.egg\flask\_compat.py", line 39, in reraise
    raise value
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\flask-1.1.2-py3.8.egg\flask\app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\flask-1.1.2-py3.8.egg\flask\app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\verzettler-0.1.0-py3.8.egg\verzettler\bin\zk_server.py", line 79, in dashboard
    zk_name_pie_chart(zk=zk),
  File "C:\Users\Bios-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\verzettler-0.1.0-py3.8.egg\verzettler\bokeh_plots.py", line 78, in zk_name_pie_chart
    data["color"] = Reds[len(x)]
KeyError: 1
127.0.0.1 - - [08/Oct/2020 10:42:07] "GET /dashboard HTTP/1.1" 500 -

I read in the code, after adding some notes just in case (line 77 of bokeh_plots says # fixme: problems if we have <= 2 zks) the error persists

klieret commented 3 years ago

I will take a look at this tomorrow! You can probably also just disable the problematic plot...

Pablo2m commented 3 years ago

Yes, it was trivial to disable that plot. imagen

klieret commented 3 years ago

Great!

Btw, I think in the longer term we might also want to get rid of bokeh and use plotly instead. Just so much easier to use I think

klieret commented 3 years ago

But I think it makes sense to close this issue now and rather make separate issues for things that need fixing.

Pablo2m commented 3 years ago

Thanks!