File permission denied error when using utf8
Hi, installed pipreqsnb version 0.2.3 today with pip.
When running pipreqsnb --encoding=utf8 on a jupyter notebook in a folder where my current user has full rights, I get permission denied error in following error trace:
pipreqs --encoding utf8 --savepath /requirements.txt .//__temp_pipreqsnb_folder/ Traceback (most recent call last): File "c:\anaconda3\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\anaconda3\lib\runpy.py", line 85, in run_code exec(code, run_globals) File "C:\Anaconda3\Scripts\pipreqs.exe_main.py", line 7, in
File "c:\anaconda3\lib\site-packages\pipreqs\pipreqs.py", line 470, in main init(args) File "c:\anaconda3\lib\site-packages\pipreqs\pipreqs.py", line 460, in init generate_requirements_file(path, imports) File "c:\anaconda3\lib\site-packages\pipreqs\pipreqs.py", line 165, in generate_requirements_file with _open(path, "w") as out_file: File "c:\anaconda3\lib\contextlib.py", line 112, in enter return next(self.gen) File "c:\anaconda3\lib\site-packages\pipreqs\pipreqs.py", line 88, in _open file = open(filename, mode) PermissionError: [Errno 13] Permission denied: '/requirements.txt'
This permission denied error does not occur if I run without the encoding option. However, I need the encoding option as otherwise I get a charmp error.
jupyter version: 1.0.0 python version: 3.7.10 pip version: 21.0.1 conda version: 4.10.1
Hey, could you provide me the full command that you are running? Thanks!
pipreqsnb --encoding=utf8 LitRevCoding_ContingencyAnalysisGraph.ipynb
Thanks, since I don't have a Windows OS currently available to make the tests, can I ask you to run the same command and add a specific file in your Desktop or home directory where you have write perssions?
you have to use the savepath argument output_file
for example C:\Users\YourUser\Documents\requirements.txt
pipreqsnb --encoding=utf8 LitRevCoding_ContingencyAnalysisGraph.ipynb --savepath C:\Users\YourUser\Desktop\requirements.txt
I just want to try if this workaround is a fix. Thanks!
I can give you the following observations:
-
pipreqsnb --encoding=utf8 LitRevCoding_ContingencyAnalysisGraph.ipynb --savepath="C:\Users\Philipp Willms\requirement1.txt"leads to following output
pipreqs --encoding utf8 --savepath C:\Users\Philipp Willms\requirements1.txt .//__temp_pipreqsnb_folder/ Usage: pipreqs [options] [< path >]
- Using a target file directory without spaces in directory name, your workaround works.
pipreqsnb --encoding=utf8 LitRevCoding_ContingencyAnalysisGraph.ipynb --savepath "C:\Users\Public\requirements.txt"
INFO: Successfully saved requirements file in C:\Users\Public\requirements.txt
Based on that I would conclude that it is less a permission but rather an encoding / filesystem topic. I hope this helps!
Exactly, thank you for the feedback. I was suspecting that is something related to the filesystem/os . I just wanted to make sure before changing the code.
There are some things in pipreqsnb that are kind of hardcoded. So I will use some library that to config the paths and working dirs instead of writing the dirs by my self and I think that everything will work fine.
In the meantime you can set the savepath and I let you know when I have the new release ready, I have some stuff to finish but I think that I will have it in a couple of days. Sorry for the inconveniences.
Cheers.
Hi @PhilippWillms , I think I hace a patch. Would you mind uninstalling the repo and installing it from source and see if the bug still persists?
- activate the env that you are using
- uninstall your current version
pip uninstall pipreqsnb -
pip install https://github.com/ivanlen/pipreqsnb/archive/master.zip
If this solves the problem I will upload it to pypi so the pip install pipreqsnb is updated.
Thanks!
Unfortunately, now even the workaround with the filepath w/o spaces does not work anymore.
pipreqsnb --encoding=utf8 LitRevCoding_ContingencyAnalysisGraph.ipynb --savepath "C:\Users\Public\requirements.txt"
as well as pipreqsnb --encoding=utf8 LitRevCoding_ContingencyAnalysisGraph.ipynb
lead to following output
Usage: pipreqs [options] [
]
Hey @PhilippWillms , I am trying different options and everything seems to be working:
(base) C:\Users\Administrator\Downloads\pipreqsnb-bugfix-windows_permisson\pipreqsnb-bugfix-windows_permisson>pipreqsnb tests --encoding=utf8 --savepath reqs.txt
pipreqs --encoding utf8 --savepath reqs.txt tests
INFO: Successfully saved requirements file in reqs.txt
(base) C:\Users\Administrator\Downloads\pipreqsnb-bugfix-windows_permisson\pipreqsnb-bugfix-windows_permisson>pipreqsnb tests --encoding=utf8 --savepath "C:\Users\Administrator\Desktop\reqs.txt"
pipreqs --encoding utf8 --savepath C:\Users\Administrator\Desktop\reqs.txt tests
INFO: Successfully saved requirements file in C:\Users\Administrator\Desktop\reqs.txt
and also with specific files instead of folders
(base) C:\Users\Administrator\Downloads\pipreqsnb-bugfix-windows_permisson\pipreqsnb-bugfix-windows_permisson>pipreqsnb tests\autoencoder_test.ipynb --savepath reqs.txt --encoding utf8
pipreqs --encoding utf8 --savepath reqs.txt C:\Users\Administrator\Downloads\pipreqsnb-bugfix-windows_permisson\pipreqsnb-bugfix-windows_permisson\__temp_pipreqsnb_folder
INFO: Successfully saved requirements file in reqs.txt
and also I tried to reproduce your syntax completely (I only changed the target filename)
(base) C:\Users\Administrator\Downloads\pipreqsnb-bugfix-windows_permisson\pipreqsnb-bugfix-windows_permisson>pipreqsnb --encoding=utf8 tests\autoencoder_test.ipynb --savepath="C:\Users\Administrator\Desktop\requirements.txt"
pipreqs --encoding utf8 --savepath C:\Users\Administrator\Desktop\requirements.txt C:\Users\Administrator\Downloads\pipreqsnb-bugfix-windows_permisson\pipreqsnb-bugfix-windows_permisson\__temp_pipreqsnb_folder
INFO: Successfully saved requirements file in C:\Users\Administrator\Desktop\requirements.txt
(base) C:\Users\Administrator\Downloads\pipreqsnb-bugfix-windows_permisson\pipreqsnb-bugfix-windows_permisson\tests>pipreqsnb autoencoder_test.ipynb --encoding=utf8 --savepath=C:\Users\Administrator\Desktop\tessst.txt
pipreqs --encoding utf8 --savepath C:\Users\Administrator\Desktop\tessst.txt C:\Users\Administrator\Downloads\pipreqsnb-bugfix-windows_permisson\pipreqsnb-bugfix-windows_permisson\tests\__temp_pipreqsnb_folder
INFO: Successfully saved requirements file in C:\Users\Administrator\Desktop\tessst.txt
I don't know how to reproduce your issue.
I am running python in a virtual env created using conda on Windows. Then I installed pipreqsnb following the command that I provided you.
I don't know how to reproduce the issue, but check that when you target a specific ipynb file, a temporal folder is created. In my particular case it is created in the same directory as the target file (C:\Users\Administrator\Downloads\pipreqsnb-bugfix-windows_permisson\pipreqsnb-bugfix-windows_permisson\tests\__temp_pipreqsnb_folder) for the last example, so the patch seems to be working at least for me.
Hey @ivanlen ,
I figured out what is still open: The error I reported 23 hours ago seems to be related to the fact that I am running pipreqnsnb for a file in a folder with a space in the file path.
(base) C:\Users\Philipp Willms\git\PhilippsPythonStuff\ContingencyAnalysis>pipreqsnb LitRevCodingContingencyAnalysisGraph.ipynb --encoding=utf8 --savepath reqs.txt
However, if give full file path within quotation marks in specifying file input for pipreqnb command, then it works
pipreqsnb "C:\Users\Philipp Willms\git\PhilippsPythonStuff\ContingencyAnalysis\LitRevCodingContingencyAnalysisGraph.ipynb" --encoding=utf8 --savepath reqs.txt