Nikola in a virtual env and txt2tags

31 views
Skip to first unread message

Mike Ray

unread,
Jul 16, 2016, 2:05:36 PM7/16/16
to nikola-...@googlegroups.com
Hello,

I am trying to use Nikola in a virtual environment.

I have got the environment created correctly and everything is wrking
except, some of my pages are written with txt2tags.

I have installed txt2tags from github in the venv. It is correctly in:

/home/mike/virtualenv/Envs/raspberryvi/bin

And when I run txt2tags outside of Nikola it is the correct one which is
running because I have put a print statement in the top of the script
and the shebang line has the right path in it.

But when Nikola tries to render a txt2tags page it claims txt2tags is
not installed.

It is as if Nikola is not "seeing" the correct path.

When, in the venv I type:

echo $PATH

The first entry is a path to the bin directory of the virtual environment.

Any ideas?

Mike


--
Michael A. Ray
Analyst/Programmer
Witley, Surrey, South-east UK

Eyes-free Linux:
http://eyesfreelinux.ninja/

Raspberry VI:
http://www.raspberryvi.org/

Chris Warrick

unread,
Jul 16, 2016, 2:08:01 PM7/16/16
to Nikola—Discuss
> --
> You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

We use this Python code:

from txt2tags import exec_command_line

Can you run this from a Python interpreter that lives in the same
environment as Nikola? (try `nikola console`) Also why txt2tags? Why
not use something more standard like Markdown?
--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

Mike Ray

unread,
Jul 16, 2016, 2:36:49 PM7/16/16
to nikola-...@googlegroups.com
Hello Chris,

I like the table syntax of txt2tags. One of the things which is missing
from markdown. My sites have a mix of markdown and txt2tags. I only use
txt2tags for those pages which have tables. I may convert them to
kramdown since I wrote the kramdown plugin.

Here is the result of the code:

Traceback (most recent call last):
File "<stdin>", line 2, in <module>
from txt2tags import exec_command_line
ImportError: No module named txt2tags

And here is the text of txt2tags, which is in
/home/mike/virtualenv/Envs/raspberryvi/bin :

#!/home/mike/virtualenv/Envs/raspberryvi/bin/python
# EASY-INSTALL-SCRIPT: 'txt2tags==2.6','txt2tags'
__requires__ = 'txt2tags==2.6'
__import__('pkg_resources').run_script('txt2tags==2.6', 'txt2tags')


When I put a print in the line below the shebang and run it in the venv
it works.

Chris Warrick

unread,
Jul 16, 2016, 2:41:32 PM7/16/16
to Nikola—Discuss
On 16 July 2016 at 20:36, Mike Ray <mi...@raspberryvi.org> wrote:
> Hello Chris,
>
> I like the table syntax of txt2tags. One of the things which is missing
> from markdown. My sites have a mix of markdown and txt2tags. I only use
> txt2tags for those pages which have tables. I may convert them to
> kramdown since I wrote the kramdown plugin.

reStructuredText supports an even simpler syntax:
https://getnikola.com/quickref.html#tables

> Here is the result of the code:
>
> Traceback (most recent call last):
> File "<stdin>", line 2, in <module>
> from txt2tags import exec_command_line
> ImportError: No module named txt2tags
>
> And here is the text of txt2tags, which is in
> /home/mike/virtualenv/Envs/raspberryvi/bin :
>
> #!/home/mike/virtualenv/Envs/raspberryvi/bin/python
> # EASY-INSTALL-SCRIPT: 'txt2tags==2.6','txt2tags'
> __requires__ = 'txt2tags==2.6'
> __import__('pkg_resources').run_script('txt2tags==2.6', 'txt2tags')
>
>
> When I put a print in the line below the shebang and run it in the venv
> it works.
>
> Mike

Nikola is probably in a different environment, try

$ which nikola

to find out what it is, and install txt2tags there. Or just install
user-wide (pip install --user)

Mike Ray

unread,
Jul 16, 2016, 2:47:24 PM7/16/16
to nikola-...@googlegroups.com
It's in the right env and txt2tags is the right version.

pip install txt2tags

Says requirement already satisfied.

Chris Warrick

unread,
Jul 16, 2016, 2:50:06 PM7/16/16
to Nikola—Discuss
In `nikola console`, run:

import nikola, sys
print(nikola.__file__)
print(sys.path)

and show me the results.

Mike Ray

unread,
Jul 16, 2016, 3:12:36 PM7/16/16
to nikola-...@googlegroups.com
Here's the result Chris:

(raspberryvi) pts/0 mike@intruder:~/virtualenv/projects/raspberryvi$
nikola console
[2016-07-16T19:08:15Z] WARNING: Nikola: Could not guess locale for
language en, using locale C
Scanning posts..............done!
Python 2.7.9 (default, Mar 1 2015, 12:57:24)
Type "copyright", "credits" or "license" for more information.

IPython 5.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.


Nikola v7.7.9 -- IPython Console (conf = configuration file, site = site
engine, commands = nikola commands)

In [1]:

In [1]: import nikola, sys
...: print(nikola.__file__)
...: print(sys.path)
...:
/home/mike/virtualenv/Envs/raspberryvi/local/lib/python2.7/site-packages/nikola/__init__.pyc
['/home/mike/virtualenv/Envs/raspberryvi/bin',
'/home/mike/virtualenv/Envs/raspberryvi/lib/python2.7',
'/home/mike/virtualenv/Envs/raspberryvi/lib/python2.7/plat-x86_64-linux-gnu',
'/home/mike/virtualenv/Envs/raspberryvi/lib/python2.7/lib-tk',
'/home/mike/virtualenv/Envs/raspberryvi/lib/python2.7/lib-old',
'/home/mike/virtualenv/Envs/raspberryvi/lib/python2.7/lib-dynload',
'/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/home/mike/virtualenv/Envs/raspberryvi/local/lib/python2.7/site-packages',
u'',
'/home/mike/virtualenv/Envs/raspberryvi/local/lib/python2.7/site-packages/IPython/extensions']

In [2]:
Reply all
Reply to author
Forward
0 new messages