Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 ImportError: cannot import name 'path'
#1
Hi All,

I've written a small piece of code to get the number of files in a directory.
I installed the path module as well, but still i'm getting the error :

ImportError: cannot import name 'path' while running the code.

Code:
root@Anon:# cat cleanup.py 
#!/usr/bin/python3


from path import path
d=('/home/us3r/sample/')
num_files=len(d.files())
print(num_files)
I'm executing the code from the Linux terminal as below:

./cleanup.py

Thanks in Advance!!!
Quote
#2
Try to import os.
See my tread...https://python-forum.io/Thread-Looping-through-music-files
Quote
#3
using pathlib see https://stackoverflow.com/a/43430592
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  ImportError: cannot import name 'gui' from 'appJar' CabbageMan 1 148 Sep-04-2019, 07:31 PM
Last Post: Gribouillis
  ImportError: cannot import name 'gphoto2' from 'sh' evvvonder 1 273 Jul-02-2019, 12:51 AM
Last Post: metulburr
  ImportError: cannot import name 'DEFUSEDXML' from 'openpyxl' kaninaba94 1 704 Mar-24-2019, 11:55 AM
Last Post: kaninaba94
  .pth file does not show up in sys.path when configuring path. arjunsingh2908 2 1,052 Jul-03-2018, 11:16 AM
Last Post: arjunsingh2908
  can not open .exe file generated by py2exe: ImportError: cannot import name _remove_d py2exe 0 728 May-22-2018, 09:57 AM
Last Post: py2exe
  ImportError: cannot import name 'Main' => Cannot install module with pip Oby4455 5 14,224 Jan-09-2018, 06:51 PM
Last Post: Gribouillis
  easysnmp ImportError: cannot import name Session anna 2 2,652 Jan-03-2018, 01:28 PM
Last Post: anna
  Pygame*import pygame ImportError: No module named pygame CASPERHANISCH 1 5,130 Jun-05-2017, 09:50 PM
Last Post: nilamo

Forum Jump:


Users browsing this thread: 1 Guest(s)