I try to write a file with python on Windows 10. The command works when I use the python 3.7 installed outside any environment, but not when I use a python 3.7 installed inside a conda environment. The following error occurs :
Traceback (most recent call last):
File "foo.py", line 1, in <module>
with open("foo.txt", "w") as f:
PermissionError: [Errno 13] Permission denied: 'foo.txt'
This works :
py foo.py
This raises the PermissionError :
conda create --name myenv python=3.7
conda activate myenv
python foo.py
# foo.py
with open("foo.txt", "w") as f:
pass
The python location is C:\Users\myusername\miniconda3\envs\myenv\python.exe
for the python inside the conda environment and C:\Windows\py.exe
for the other one.
The current user is an administrator. I already tried to run the Anaconda prompt as administrator, and also to give full permission to Everyone for the current folder. I don't understand why it does not work.
Edit
I am actually able to run the script using the shortcut method explained here but I would prefer to find a solution that does not require me to create a shortcut for each script I write in my conda environments.