Can .conda_trash files be safely deleted from Scripts folder in Anaconda? - python

I am using Anaconda python distributin. Under Scripts folder, I see several ~.conda_trash files. Can these files be safely deleted?
I am using Windows 10, anaconda 2020_07.

The .conda_trash file are generated on windows when conda tries to delete folder containing in-use files. As windows can't delete files that are in use (i think linux users don't meet the .conda_trash problem).
There is a delete_trash function at boot that scans the entire tree in search for those files and deletes them.
So basically conda should be able to get rid of those files by itself. But if those are not needed anymore (and take too much time at boot), it shouldn't be a poblem to manually delete them.

I have tested on my PC that the ~.conda_trash files can be deleted from Scripts folder without affecting anaconda distribution.

Related

How to bundle Python apps with asset dependencies for end users?

I have a Tkinter app that uses images included in the same folder as the .py file. pyinstaller script.py produces an executable that runs but does not open any windows. This is because it is looking for images that don't exist in the same subdirectory. When I copy the important images to the dist folder Pyinstaller creates, the application runs correctly.
However, I would like to have a single executable that I can share with other users that doesn't also require them to have the images stored. The images should be bundled with the software somehow, like how commercial software (usually) doesn't require you to download assets separately from the program itself.
Is there a way to bundle Python programs and the assets they use into single-click applications?
Note that I am using Python 3 on Linux Mint. I am also something of a novice, so don't be surprised if I'm missing something obvious here.
It appears I've solved my own problem.
Instead of having the images included in the same folder as main.py and using the resulting short relative filepath to reach them, install the images in an appropriate space in the system directory tree (I used /home/$USER$/.$PROGRAMNAME$/) and have the program access the files using the absolute path to that directory. This will allow you to copy the program anywhere on your computer you want and have it run without a problem.
However, if you want to share it with someone else, you'll need to also include an installation script that places the assets in the correct directory on their computer.

How to prevent spyder from creating temp files in the same directory of the file I save

I installed spyder with pip (not with anaconda).
Whenever I save a .py file, spyder also generates a temp file containing a copy of the file source, in the same directory. Something like this
where each file starting with "tmp" contains the source of a different version of main.py. In the past, when I installed spyder with Anaconda, this never occurred.
Is there a way to deactivate this feature? Or at least to force spyder to save these temp files somewhere else?
Not sure if you are still troubled by this issue. Are you using Dropbox or some similar services?
I've met the same problem as you did, and I found the reason on Github, see #13041.
If you can try to work outside Dropbox, you don't see any tmp files. This works for me and hope it can help you.

Windows installer does not clean up *.pyc and *.pyo files on uninstall

I have a python app (PyQt4 app) for which I create a windows MSI installer using setuptools.
python setup.py bdist_msi
The MSI installs the application correctly (under site-packages). On uninstalling (msiexec /x) it also removes all the associated *.py files. However, the compiled files still persist on disk. Subsequently when I run the new version of the app, it still picks up stale *.pyc files.
Is there an option to somehow tell the MSI to clean up *.pyc and *.pyo files?
(I suspect this is because *.pyc and *.pyo files were not installed by the MSI in the first place, but rather created upon running python.exe. But would appreciate some guidance).
Thanks
You are absolutely correct. Msi do not remove those file because they were not deployed by installer. In order to clean them up you have to create custom-action which will delete all *.pyc and *.pyo files.
Just in case you know exact filenames you could add dummy (empty) files so that installer would consider them it's "property" and delete them on uninstall.

clean up .pyc files in virtualenv stored in souce repository after the fact?

I've created a virtualenv for my project and checked it into source control. I've installed a few projects into the virtualenv with pip: django, south, and pymysql. After the fact I realized that I had not set up source control for ignoring .pyc files. Could there be any subtle problems in simply removing all .pyc files from my project's repository and then putting in place the appropriate file ignore rules? Or is removing a .pyc file always a safe thing to do?
That is fine, just remove them!
Python auto-generates them from the corresponding .py file any time it wants to, so you needn't worry about simply deleting them all from your repository.
A couple of related tips - if you don't want them generated at all on your local dev machine, set the environment variable PYTHONDONTWRITEBYTECODE=1. Python 3.2 fixed the annoyance of source folders cluttered with .pyc files with a new __pycache__ subfolder

Keeping the .dll and .pyd files in other directory

I am using cx_Freeze to convert Python scripts to Windows executable. I am using cxfreeze script present in the Scripts directory. I want the executable generated by cxfreeze to be in a different directory and the .dll's and .pyd's in a different one. When I tried to put the two of them in separate directories the .exe did not work I got
The application has failed to start because python33.dll was not found. Try reinstalling to fix this problem
I know this happends because the executable and (dll's & .pyd's) are located in different directories. Is there a way to keep them in different directories ?
I am using the following command to generate the executable
C:\Python33\Scripts>cxfreeze C:\Users\me\Desktop\setup.py --target-name=setup.exe --target-dir=C:\Users\me\Desktop\new_dir
Python for Windows really requires that the main pythonXX.dll (in this case, python33.dll) exists in C:\windows\system32\
In all of our various combinations of installing Python to different locations, network drives, etc. we've always had to use a little batch file to copy pythonXX.dll into the system32 dir.
I don't think PATH manipulation will work for you, just try copying the dll to system32 and see if your issues go away.
Then again, if you installed another version of Python to say C:\Python33 , then that windows-based installer will do this for you, and you'll be able to run your other Python location.

Categories

Resources