I suppose you could create your own conda package, which will be mostly empty except for a special activation script in ${PREFIX}/etc/conda/activate.d/
. The activation script will check if opencv-python
is installed, and remove it.
This recipe would do it:
recipe/
├── meta.yaml
└── uninstall-opencv-python.sh
# meta.yaml
package:
name: my-hack-to-uninstall-opencv-python
version: 0.1
build:
number: 0
noarch: generic
script:
- mkdir -p {{ PREFIX }}/etc/conda/activate.d/
- cp {{ RECIPE_DIR }}/uninstall-opencv-python.sh {{ PREFIX }}/etc/conda/activate.d/
# uninstall-opencv-python.sh
if (pip list | grep opencv-python > /dev/null); then
echo "Uninstalling opencv-python"
pip uninstall opencv-python
fi
Build that recipe and upload the resulting package to your own channel on anaconda.org
. Then, add a line to your environment.yml
file:
- mychannel::my-hack-to-uninstall-opencv-python
The only downside is that it will run that script every time the environment is activated. But it's a relatively fast script, so maybe that's not a problem. Obviously any solution to this particular problem will be somewhat of a hack, no matter what you come up with.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…