pathlib type error

Chris Angelico rosuav at gmail.com
Sat Jan 3 13:06:20 CET 2015


On Sat, Jan 3, 2015 at 10:55 PM, Georg Grafendorfer
<georg.grafendorfer at gmail.com> wrote:
> I'm using Debian 8 Jessie on an AMD64 machine.
> Getting this error:
>
> ~$ python3
> Python 3.4.2 (default, Oct  8 2014, 10:45:20)
> [GCC 4.9.1] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from pathlib import Path
>>>> p = Path("/etc")
>>>> q = p / "init.d"
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: unsupported operand type(s) for /: 'PosixPath' and 'str'
>>>>

Unable to reproduce:

rosuav at dewey:~$ python3
Python 3.4.2 (default, Oct  8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import Path
>>> p = Path("/etc")
>>> q = p / "init.d"
>>> q
PosixPath('/etc/init.d')
>>> pathlib.__file__
'/usr/lib/python3.4/pathlib.py'

Is it possible you have another pathlib installed? It's available on
PyPI, maybe you got it with pip - check 'pip freeze|grep pathlib' on
the off-chance. Is your pathlib.__file__ the same as mine?

ChrisA



More information about the Python-list mailing list