Open tommai78101 opened 3 years ago
I uninstalled my local Python 3.8.8 and used pyenv-win, since I realized I need to be able to switch different Python environments.
After installing pyenv-win, I did all the setup:
# Python is version 3.9.4.
pyenv rehash
pyenv install 3.9.4
pyenv global 3.9.4
# Installed yapf
python -m pip3 install -U yapf
# Got yapf 0.31.0
yapf --version
# Finally, ran the yapf with the .STYLE.YAPF file in C:\Users\tomma\.config\yapf\style\ directory
PS D:\Documents\PythonProjects\testPython> python -m yapf .\example.py
Traceback (most recent call last):
File "C:\Users\tomma\.pyenv\pyenv-win\versions\3.9.4\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\tomma\.pyenv\pyenv-win\versions\3.9.4\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\tomma\.pyenv\pyenv-win\versions\3.9.4\lib\site-packages\yapf\__main__.py", line 18, in <module>
yapf.run_main()
File "C:\Users\tomma\.pyenv\pyenv-win\versions\3.9.4\lib\site-packages\yapf\__init__.py", line 362, in run_main
sys.exit(main(sys.argv))
File "C:\Users\tomma\.pyenv\pyenv-win\versions\3.9.4\lib\site-packages\yapf\__init__.py", line 126, in main
File "C:\Users\tomma\.pyenv\pyenv-win\versions\3.9.4\lib\site-packages\yapf\__init__.py", line 227, in _FormatFile
File "C:\Users\tomma\.pyenv\pyenv-win\versions\3.9.4\lib\site-packages\yapf\yapflib\yapf_api.py", line 94, in FormatFile
reformatted_source, changed = FormatCode(
File "C:\Users\tomma\.pyenv\pyenv-win\versions\3.9.4\lib\site-packages\yapf\yapflib\yapf_api.py", line 142, in FormatCode
style.SetGlobalStyle(style.CreateStyleFromConfig(style_config))
File "C:\Users\tomma\.pyenv\pyenv-win\versions\3.9.4\lib\site-packages\yapf\yapflib\style.py", line 708, in CreateStyleFromConfig
config = _CreateConfigParserFromConfigFile(style_config)
File "C:\Users\tomma\.pyenv\pyenv-win\versions\3.9.4\lib\site-packages\yapf\yapflib\style.py", line 743, in _CreateConfigParserFromConfigFile
with open(config_filename) as style_file:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\tomma/.config\\yapf\\style'
By the way, I can confirm the .STYLE.YAPF file works normally, if I put the file in the parent directory of all of my Python projects:
D:\Documents\PythonProjects\
. Just running yapf .\testPython\example.py
works flawlessly after I put the .STYLE.YAPF file in the parent directory there.
In YAPF, there is a directory that it looks up, to find a .STYLE.YAPF file:
~/.config/yapf/style/
On Windows 10, this directory is located at:
C:\Users\tomma\.config\yapf\style\
I have placed my .STYLE.YAPF file in this directory.
When executing YAPF in Powershell, it would throw a "Permissions Denied" error because of an incorrectly parsed forward slash/backwards slash in the PATH it is attempting to look in for the .STYLE.YAPF file. You can easily tell by checking the last line of the stack trace (below) for this path:
C:\\Users\\tomma/.config\\yapf\\style
The error should have thrown something like "FileNotFoundError" instead of a "PermissionsError", but I digress, since the .STYLE.YAPF file is placed there. I did double-check to make sure that the file permissions and folder permissions are set to FULL CONTROL under my account,
tomma
. Thus, I don't believe it's a permissions issue.Stack trace:
Maybe it has to do with the YAPF file, given below?
System information: