Conda-pack: CondaPackError: files managed by conda were

6.7k Views Asked by At

So, I have a python project where all my tests run but then I do:

conda install -y conda-pack

which succeeds and when I run:

conda-pack

I get a lengthy complaint:

Collecting packages...
CondaPackError: 
Files managed by conda were found to have been deleted/overwritten in the
following packages:

- conda-pack 0.6.0:
    lib/python3.1/site-packages/conda_pack-0.6.0.dist-info/INSTALLER
    lib/python3.1/site-packages/conda_pack-0.6.0.dist-info/LICENSE.txt
    lib/python3.1/site-packages/conda_pack-0.6.0.dist-info/METADATA
    + 19 others
- types-requests 2.26.0:
    lib/python3.1/site-packages/requests-stubs/METADATA.toml
    lib/python3.1/site-packages/requests-stubs/__init__.pyi
    lib/python3.1/site-packages/requests-stubs/adapters.pyi
    + 41 others
- jsonschema 4.2.1:
    lib/python3.1/site-packages/jsonschema-4.2.1.dist-info/COPYING
    lib/python3.1/site-packages/jsonschema-4.2.1.dist-info/INSTALLER
    lib/python3.1/site-packages/jsonschema-4.2.1.dist-info/METADATA
    + 39 others
- types-setuptools 57.4.2:
    lib/python3.1/site-packages/pkg_resources-stubs/METADATA.toml
    lib/python3.1/site-packages/pkg_resources-stubs/__init__.pyi
    lib/python3.1/site-packages/pkg_resources-stubs/py31compat.pyi
    + 56 others
<snip>

I see no issues in conda list and I can still run my tests. I see no issues with my environment. Ideas?

4

There are 4 best solutions below

1
Fei On

This should be related to this issue: https://github.com/conda/conda-pack/issues/198

The root cause is that the image is trying to use python3.10 and conda-pack parse it as python3.1.

They claimed to have fixed it in conda-pack 0.7.0 (release note) but I was using 0.7.0 and still see this problem.

One workaround is to specify another python version in a new env:

conda create -n new_env python=3.9 ${other_packages}
conda install conda-pack

conda-pack -n new_env ${your_other_options}
0
Rriskit On

I think the problem is still there in conda-pack 0.7.0 in the unix-world and will only appear for python 3.10 and upward. It might be dependent on the conda version, but many users do not have the rights to update conda (as is the case for me). Reason are the symbolic links generated by python, which direct python 3.1 packages/programs to python 3.10. Conda-pack does not understand that correctly und searches for python3.1 files.

Solution is a) to update conda if possible b) if that fails to exclude those python3.1 references (running conda-pack in the environment, say myenv, you want to pack - will generate myenv.tar.gz):

conda-pack -f --ignore-missing-files --exclude lib/python3.1
0
Chandler's Sexyface On

It might be that the files installed by pip have overridden those installed by conda, causing conflicts. Reinstalling the conflicting packages with conda should resolve the problem. For example:

conda install conda-pack==0.6.0
0
Alex On

As of January 2024, the problem is solved in the latest conda-pack package (0.7.1).

Just create a new env for conda-pack:

conda create -y -n conda_pack
conda activate conda_pack
conda install -c conda-forge conda-pack

then run it:

conda-pack --prefix /path/to/env/name_of_env -o ~/name_of_env .tar.gz