natsort problems

631 views
Skip to first unread message

Detlev Zundel

unread,
Jan 28, 2021, 5:20:04 PM1/28/21
to nikola-...@googlegroups.com
Hi,

trying to build my site, I now encounter this problem:

dzu@krikkit:~/blog (master)$ nikola build
Scanning posts.[2021-01-28 23:11:29] ERROR: scan_posts: Error reading post posts/a-mathematicians-lament.rst
[2021-01-28 23:11:29] ERROR: Nikola: Error reading timeline
[2021-01-28 23:11:29] ERROR: Nikola: Error loading tasks. An unhandled exception occurred.
[2021-01-28 23:11:29] ERROR: Nikola: AttributeError: module 'natsort' has no attribute 'natsorted'
[2021-01-28 23:11:29] WARNING: Nikola: To see more details, run Nikola in debug mode (set environment variable NIKOLA_DEBUG=1) or use NIKOLA_SHOW_TRACEBACKS=1
dzu@krikkit:~/blog (master)$ pip3 list | grep 'natsort\|Nikola'
natsort 7.1.0
Nikola 8.1.2
dzu@krikkit:~/blog (master)$

This is Nikola v8.1.2 running on Debian testing. Looking around I see
that python3 is having problems doing an import statement that I believe
should work:

dzu@krikkit:~$ python3
Python 3.9.1+ (default, Jan 20 2021, 14:49:22)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from natsort import natsorted
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'natsorted' from 'natsort' (/home/dzu/.local/lib/python3.9/site-packages/natsort/__init__.py)
>>>
dzu@krikkit:~$

It works nicely in python2:

dzu@krikkit:~/blog (master)$ python2
Python 2.7.18 (default, Apr 20 2020, 20:30:41)
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from natsort import natsorted
>>>
dzu@krikkit:~/blog (master)$

Does anyone have a clue for me on how to fix this to make Nikola work
again?

Thanks in advance
Detlev

--
Any fool can write code that a computer can understand. Good
programmers write code that humans can understand.
-- Martin Fowler

Chris Warrick

unread,
Jan 28, 2021, 5:40:00 PM1/28/21
to Nikola—Discuss
Works for me. Uninstall `natsort` and reinstall. If that doesn’t fix
it, inspect the __init__.py file and look for any weird things. Also,
we recommend using a venv.

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

Detlev Zundel

unread,
Jan 29, 2021, 3:31:11 AM1/29/21
to nikola-...@googlegroups.com
Hi Chris,

thanks for your quick answer!

[...]

> Works for me. Uninstall `natsort` and reinstall.

Urgh. Indeed this fixed the problem. Hm. So that means files below
.local/lib/python3.9/site-packages have deen damaged somehow. I need to
remember this when more problems come up.

Thanks!
Detlev

--
Learn from the mistakes of others. You can never live long enough to
make them all yourself.
-- Groucho Marx

Chris Warrick

unread,
Jan 29, 2021, 7:47:19 AM1/29/21
to Nikola—Discuss
On Fri, 29 Jan 2021 at 09:31, Detlev Zundel <d...@member.fsf.org> wrote:
>
> Hi Chris,
>
> thanks for your quick answer!
>
> [...]
>
> > Works for me. Uninstall `natsort` and reinstall.
>
> Urgh. Indeed this fixed the problem. Hm. So that means files below
> .local/lib/python3.9/site-packages have deen damaged somehow. I need to
> remember this when more problems come up.

Installing stuff to ~/.local/ is not recommended, because you can get
conflicts between packages. Use a venv instead, as prescribed in the
Getting Started guide: https://getnikola.com/getting-started.html
Reply all
Reply to author
Forward
0 new messages