Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

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

like image 838
Van-Sama Avatar asked Jan 11 '20 09:01

Van-Sama


1 Answers

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.

like image 146
Jaideep Shekhar Avatar answered Nov 15 '22 01:11

Jaideep Shekhar