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
  FileNotFoundError...System cannot find the path specified alex9745 27 2,712 10 hours ago
Last Post: kingmaker007
  Help | How to make Dynamic Path/Address soothsayerpg 3 126 Jul-14-2019, 03:51 PM
Last Post: DeaD_EyE
  ImportError: cannot import name 'gphoto2' from 'sh' evvvonder 1 125 Jul-02-2019, 12:51 AM
Last Post: metulburr
  Writing the Path to a file properly dcw9996 2 132 Jul-01-2019, 11:26 PM
Last Post: dcw9996
  TimeLapse Help - ImportError: No module named 'sh' evvvonder 4 199 Jun-28-2019, 10:52 PM
Last Post: evvvonder
  ImportError has not raised in pkg_resources module but expected tamilselvanvjm 2 144 Jun-19-2019, 10:06 AM
Last Post: tamilselvanvjm
  Matplotlib ImportError robertinoc 4 279 Jun-14-2019, 09:11 AM
Last Post: snippsat
  ImportError: No module named pymysql - On Apache2 for Python 2.7 on Mac Tyrone 9 556 Jun-12-2019, 07:08 PM
Last Post: Tyrone
  Help with environment path variables kuharido 0 138 Jun-07-2019, 09:18 PM
Last Post: kuharido
  sys.path miss dist-packages in a virtual env. chomwitt 2 148 May-23-2019, 08:08 PM
Last Post: chomwitt

Forum Jump:


Users browsing this thread: 1 Guest(s)