I have Anaconda installed with a Python 3.9 environment under my personal user account on Windows. I use runfile
to run a *.py
file from the Spyder console. I normally have the Spyder editor closed and use Cygwin and Vim tabs/subwindows to do anything text related.
When runfile
encounters an error, the Spyder editor window opens. I usually close it right away, but sometimes, I’m just trying to maintain mental flow in getting a code pattern to work via trial and error. At some point, an error caused the following file to open:
/c/Users/User.Name/AppData/Local/anaconda3/envs/py39/Lib/site-packages/pandas/core/reshape/merge.py
This creates a hazard in that I may inadvertently make some changes in merge.py
, e.g., if keyboard focus not where I thought it was. However, I would never deliberately save any changes to the source file in a library.
It seems like changes were made anyway, and I assume that I made them. I don’t know how they got saved. Maybe when I pressed Ctrl+D
in the Spyder console to clean out the Variable Explorer, it saves the file to which the text editor is opened (I’m not really sure). The result is that merge.py
has a missing block of code
if rk is not None:
<...Here belongs the missing code...>
else:
# work-around for merge_asof(right_index=True)
right_keys.append(right.index)
if lk is not None and lk == rk: # FIXME: what about other NAs?
# avoid key upcast in corner case (length-0)
lk = cast(Hashable, lk)
Fortunately, I was able to use Cygwin’s find
to locate an almost identical merge.py
:
/c/Users/User.Name/AppData/Local/anaconda3/Lib/site-packages/pandas/core/reshape/merge.py
To prevent this from happening again, I am tempted make all files read-only by issuing one of the following in /c/Users/User.Name/AppData/Local/anaconda3
:
chmod -R u-r *
find * -type f -print0 | xargs -0 chmod u-r
However, I do need to update Anaconda or install packages. Even if I didn’t, I am not sure if Anaconda, Conda, or Python needs write access. Or any of the packages that I installed to get Apache Spark functionality. I am relatively new to Python, Anaconda, and Spark.
What is best practice for avoiding what I assume is inadvertent modificaton of library source files?