Python: PermissionError: [Errno 13] with copy_tree function in windows - python-3.x

Im just copying all files and subfolders from an specific directory using the function distutils.dir_util.copy_tree in Windows:
from distutils.dir_util import copy_tree
from datetime import datetime
directories_to_backup = {
'folder_a' : 'e:\\folder_a',
}
now = datetime.now()
backup_name_folder = now.strftime("%Y%m%d-%H%M")
for name_folder, path_folder in directories_to_backup.items():
print(f'Backuping up the folder {name_folder}')
backup_full_path = f't:\\zzzBackup\\{backup_name_folder}\\{name_folder}\\'
copy_tree(path_folder, backup_full_path)
it works fine till it get to some specific file and rise the following error:
Traceback (most recent call last):
File "C:\Users\UserR\AppData\Local\Programs\Python\Python37\lib\distutils\file_util.py", line 48, in _copy_file_contents
buf = fsrc.read(buffer_size)
PermissionError: [Errno 13] Permission denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/UserR/PycharmProjects/my_scripts/main_backup.py", line 28, in <module>
copy_tree(path_folder, backup_full_path)
File "C:\Users\UserR\AppData\Local\Programs\Python\Python37\lib\distutils\dir_util.py", line 159, in copy_tree
verbose=verbose, dry_run=dry_run))
File "C:\Users\UserR\AppData\Local\Programs\Python\Python37\lib\distutils\dir_util.py", line 159, in copy_tree
verbose=verbose, dry_run=dry_run))
File "C:\Users\UserR\AppData\Local\Programs\Python\Python37\lib\distutils\dir_util.py", line 159, in copy_tree
verbose=verbose, dry_run=dry_run))
[Previous line repeated 1 more times]
File "C:\Users\UserR\AppData\Local\Programs\Python\Python37\lib\distutils\dir_util.py", line 163, in copy_tree
dry_run=dry_run)
File "C:\Users\UserR\AppData\Local\Programs\Python\Python37\lib\distutils\file_util.py", line 151, in copy_file
_copy_file_contents(src, dst)
File "C:\Users\UserR\AppData\Local\Programs\Python\Python37\lib\distutils\file_util.py", line 51, in _copy_file_contents
"could not read from '%s': %s" % (src, e.strerror))
distutils.errors.DistutilsFileError: could not read from 'e:\folder_a\0\binlog': Permission denied
Process finished with exit code 1
How can I update the permissions in windows so my script would be able to read and copy the files?

Related

numpy loadtxt raise IOError("%s not found." % path) OSError: uest1.txt not found

My code:
import numpy as np
a = np.loadtxt('uest1.txt',delimiter=',')
print(a[0:4,:])
Error:
F:\LearnPython>python -u "c:\Machine learning\bai3\bai3.py"
Traceback (most recent call last):
File "c:\Machine learning\bai3\bai3.py", line 2, in <module>
a = np.loadtxt('uest1.txt',delimiter=',')
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\numpy\lib\npyio.py", line 961, in loadtxt
fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\numpy\lib\_datasource.py", line 195, in open
return ds.open(path, mode, encoding=encoding, newline=newline)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\numpy\lib\_datasource.py", line 535, in open
raise IOError("%s not found." % path)
OSError: uest1.txt not found.

Problem running Tensorflow (Ubuntu 19.10)

I've recently tried to install and run some python and tensorflow code from this repository.
I followed the manual installation procedure just as mentioned in the README.md present in the repository.
As I've never used tensorflow before, I had to install a lot of packages to get it up and running.
Currently, I've got tensorfow-gpu 1.13, python 3.7, and an Nvidia graphics card (mx250) on my Ubuntu 19.10 laptop, and I wish to get the code running. However, I'm having issues running the demo.sh file present with it.
Here's what I get in the err.txt when I run the command $ bash demo.sh > output.txt 2> err.txt at the cloned directory (after installing all required packages):
*** Aborted at 1575094215 (unix time) try "date -d #1575094215" if you are using GNU date ***
PC: # 0x7f92c7012ae8 ceres::internal::ProgramEvaluator<>::Evaluate()
*** SIGSEGV (#0x0) received by PID 22202 (TID 0x7f92acda5700) from PID 0; stack trace: ***
# 0x7f92c7452641 (unknown)
# 0x7f92c67dd540 (unknown)
# 0x7f92c7012ae8 ceres::internal::ProgramEvaluator<>::Evaluate()
# 0x7f92c709265f ceres::internal::TrustRegionMinimizer::EvaluateGradientAndJacobian()
# 0x7f92c7092f4a ceres::internal::TrustRegionMinimizer::IterationZero()
# 0x7f92c70972d4 ceres::internal::TrustRegionMinimizer::Minimize()
# 0x7f92c7088cbc ceres::Solver::Solve()
# 0x7f92c70899b9 ceres::Solve()
# 0x55bb3bb1a2eb colmap::BundleAdjuster::Solve()
# 0x55bb3bb78037 colmap::IncrementalMapper::AdjustGlobalBundle()
# 0x55bb3bac3f0c (unknown)
# 0x55bb3bac521d colmap::IncrementalMapperController::Reconstruct()
# 0x55bb3bac6a9b colmap::IncrementalMapperController::Run()
# 0x55bb3bbd7dfc colmap::Thread::RunFunc()
# 0x7f92c5ad9f74 (unknown)
# 0x7f92c67d1669 start_thread
# 0x7f92c578f323 clone
Traceback (most recent call last):
File "imgs2poses.py", line 11, in <module>
gen_poses(args.scenedir)
File "/home/abhigyan/Code/CVProject/LLFF/llff/poses/pose_utils.py", line 265, in gen_poses
run_colmap(basedir)
File "/home/abhigyan/Code/CVProject/LLFF/llff/poses/colmap_wrapper.py", line 70, in run_colmap
map_output = ( subprocess.check_output(mapper_args, universal_newlines=True) )
File "/home/abhigyan/anaconda3/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/home/abhigyan/anaconda3/lib/python3.7/subprocess.py", line 487, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['colmap', 'mapper', '--database_path', 'data/testscene/database.db', '--image_path', 'data/testscene/images', '--output_path', 'data/testscene/sparse', '--Mapper.num_threads', '16', '--Mapper.init_min_tri_angle', '4', '--Mapper.multiple_models', '0', '--Mapper.extract_colors', '0']' died with <Signals.SIGSEGV: 11>.
Traceback (most recent call last):
File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/abhigyan/anaconda3/lib/python3.7/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/abhigyan/anaconda3/lib/python3.7/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "imgs2mpis.py", line 10, in <module>
from llff.inference.mpi_utils import run_inference
File "/home/abhigyan/Code/CVProject/LLFF/llff/inference/mpi_utils.py", line 6, in <module>
from llff.inference.mpi_tester import DeepIBR
File "/home/abhigyan/Code/CVProject/LLFF/llff/inference/mpi_tester.py", line 1, in <module>
import tensorflow as tf
File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/abhigyan/anaconda3/lib/python3.7/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/abhigyan/anaconda3/lib/python3.7/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
mkdir: cannot create directory ‘data/testscene/outputs/’: File exists
Traceback (most recent call last):
File "imgs2renderpath.py", line 34, in <module>
poses, bds = load_data(args.scenedir, load_imgs=False)
File "/home/abhigyan/Code/CVProject/LLFF/llff/poses/pose_utils.py", line 195, in load_data
poses_arr = np.load(os.path.join(basedir, 'poses_bounds.npy'))
File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/numpy/lib/npyio.py", line 428, in load
fid = open(os_fspath(file), "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'data/testscene/poses_bounds.npy'
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
demo.sh: line 24: 22221 Aborted (core dumped) cuda_renderer/cuda_renderer data/testscene/mpis_360 data/testscene/outputs/test_path.txt data/testscene/outputs/test_vid.mp4 360 .8 18
When you are going to use Tensorflow in GPU setup, have to carefully install and configure the Tensorflow in your machine. I would like to prefer to use Ubuntu 18.04 LTS version instead of 19.xx.
Follow the installation steps from the blog: https://zhuanlan.zhihu.com/p/49166211

OSError: [Errno 8] Exec format error while reading video Moviepy

I'm trying to run a video processing code on NVIDIA TX2 using moviepy. The code is:
clip = VideoFileClip(video_file)
video_clip = clip.fl_image(process_vid)
video_clip.write_videofile(output_vid2)
I get the error in the first line. The full error is:
Traceback (most recent call last):
File "img_test.py", line 117, in <module>
clip = VideoFileClip(video_file)
File "/home/nvidia/.local/lib/python3.5/site-packages/moviepy/video/io/VideoFileClip.py", line 91, in __init__
fps_source=fps_source)
File "/home/nvidia/.local/lib/python3.5/site-packages/moviepy/video/io/ffmpeg_reader.py", line 33, in __init__
fps_source)
File "/home/nvidia/.local/lib/python3.5/site-packages/moviepy/video/io/ffmpeg_reader.py", line 256, in ffmpeg_parse_infos
proc = sp.Popen(cmd, **popen_params)
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error
I even used the refernce of this but nothing seems to work.
Any suggestions?

When trying to install GDAL with pip to a macOS I keep getting an error about a file not found, shouldn't the installer have all of the files?

When I try using pip install to get GDAL I run into an error about a file not found. I went to the location and there is definitely no folder there but shouldn't the installer install the folder it needs first?
Collecting GDAL
Using cached https://files.pythonhosted.org/packages/7c/b0/a2ecb10a68a319910c4681f452c83843b99c4ef6231d33a8e55b0104a50c/GDAL-2.4.0.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/GDAL.egg-info
writing pip-egg-info/GDAL.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/GDAL.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/GDAL.egg-info/top_level.txt
writing manifest file 'pip-egg-info/GDAL.egg-info/SOURCES.txt'
Traceback (most recent call last):
File "/private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/setup.py", line 151, in fetch_config
p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '../../apps/gdal-config': '../../apps/gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/setup.py", line 237, in get_gdal_config
return fetch_config(option, gdal_config=self.gdal_config)
File "/private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/setup.py", line 154, in fetch_config
raise gdal_config_error(e)
__main__.gdal_config_error: [Errno 2] No such file or directory: '../../apps/gdal-config': '../../apps/gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/setup.py", line 151, in fetch_config
p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gdal-config': 'gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/setup.py", line 430, in <module>
setup(**setup_kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/__init__.py", line 143, in setup
return distutils.core.setup(**attrs)
.................................
File "/private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/setup.py", line 154, in fetch_config
raise gdal_config_error(e)
__main__.gdal_config_error: [Errno 2] No such file or directory: 'gdal-config': 'gdal-config'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/js/c2_gdy711m7933z9bxcv2q5h0000gn/T/pip-install-jv2fugnm/GDAL/

FileExistsError: [Errno 17] File exists: '/root/analytics/venv-nerapi/lib/python3.6/lib-dynload' while creating virtual environment

$virtualenv -p python3.6m ../venv-nerapi
Above command gives following error.
Running virtualenv with interpreter /usr/local/bin/python3.6m
Using base prefix '/usr/local'
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/virtualenv.py", line 352, in copyfile
os.symlink(srcpath, dest)
FileExistsError: [Errno 17] File exists: '/usr/local/lib/python3.6/lib-dynload' -> '/root/analytics/venv-nerapi/lib/python3.6/lib-dynload'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/virtualenv.py", line 2343, in <module>
main()
File "/usr/local/lib/python3.6/site-packages/virtualenv.py", line 712, in main
symlink=options.symlink)
File "/usr/local/lib/python3.6/site-packages/virtualenv.py", line 927, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/usr/local/lib/python3.6/site-packages/virtualenv.py", line 1132, in install_python
copyfile(join(stdlib_dir, fn), join(lib_dir, fn), symlink)
File "/usr/local/lib/python3.6/site-packages/virtualenv.py", line 355, in copyfile
copyfileordir(src, dest, symlink)
File "/usr/local/lib/python3.6/site-packages/virtualenv.py", line 330, in copyfileordir
shutil.copytree(src, dest, symlink)
File "/usr/local/lib/python3.6/shutil.py", line 315, in copytree
os.makedirs(dst)
File "/usr/local/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
FileExistsError: [Errno 17] File exists: '/root/analytics/venv-nerapi/lib/python3.6/lib-dynload'
I followed following Github issue thread but din't find any luck.
Could any body tell whats went wrong ?
Thanks
Turns out that there was existing venv-nerapi . Deleting existing virtual env and re-creating it worked fine.

Resources