Python FileNotFound
try block should be around open. Not around prompt.
try block should be around open. Not around prompt.
UpdateWhile what I write below is true as a general answer about shared libraries, I think the most frequent cause of these sorts of message is because you’ve installed a package, but not installed the -dev version of that package. Well, it’s not lying – there is no libpthread_rt.so.1 in that listing. You probably need to re-configure and re-build … Read more
It is because os.listdir does not return the full path to the file, only the filename part; that is ‘foo.txt’, when open would want ‘E:/somedir/foo.txt’ because the file does not exist in the current directory. Use os.path.join to prepend the directory to your filename: (Also, you are not closing the file; the with block will take care of it automatically).
UpdateWhile what I write below is true as a general answer about shared libraries, I think the most frequent cause of these sorts of message is because you’ve installed a package, but not installed the -dev version of that package. Well, it’s not lying – there is no libpthread_rt.so.1 in that listing. You probably need to re-configure and re-build … Read more
Make sure the file exists: use os.listdir() to see the list of files in the current working directory Make sure you’re in the directory you think you’re in with os.getcwd() (if you launch your code from an IDE, you may well be in a different directory) You can then either: Call os.chdir(dir), dir being the … Read more