Van-Sama
Van-Sama

Reputation: 1274

AttributeError: 'PosixPath' object has no attribute 'path'

I have a python script that I'm trying to execute but i'm not sure how it's meant to be executed. I don't program in Python so i'm unfamiliar with the language. Here is the link to the script i'm trying to use. Also, a link the configuration it's using if you wish to see it. All it seems to do for what's relevant here, however, is set my path which I know is correct since other scripts (not linked here) work as expected with the configuration in that file.

Having a look at the script, I believe that the script is meant to be ran with the command line arguments: view, new, init. Thus, I ran the following in my terminal

$ lectures.py new

But I get the following traceback

Traceback (most recent call last):
  File "/usr/bin/lectures.py", line 156, in <module>
    lectures = Lectures(Path.cwd())
  File "/usr/bin/lectures.py", line 60, in __init__
    self.root = course.path
AttributeError: 'PosixPath' object has no attribute 'path'

Furthermore, my python version

$ python --version
Python 3.8.1

EDIT: I wanted to add the reference as well for what I am trying to follow

Upvotes: 13

Views: 47980

Answers (1)

Jaideep Shekhar
Jaideep Shekhar

Reputation: 886

Going through your code, I think you might mean:

self.root = course

at that line.

Path.cwd() returns:

... the current working directory, that is, the directory from where you run the script.

that is, either a WindowsPath() or a PosixPath object. I believe it is PosixPath for you, and you can verify with:

import os
print(os.name)
# posix -> Linux
# nt -> Windows

This has no attribute path, and this is what your Interpreter tells you.

Upvotes: 4

Related Questions