简体   繁体   English

pip install conda 后 Conda 损坏

[英]Conda is corrupted after pip install conda

My conda is corrupted after I run command "pip install conda".运行命令“pip install conda”后,我的 conda 损坏了。 Is there any way to recover it ?有什么办法可以恢复吗? Thanks谢谢

Here's the error I see when running conda command这是我在运行 conda 命令时看到的错误

ERROR: The install method you used for conda--probably either `pip install conda`
or `easy_install conda`--is not compatible with using conda as an application.
If your intention is to install conda as a standalone application, currently
supported install methods include the Anaconda installer and the miniconda
installer.  You can download the miniconda installer from
https://conda.io/miniconda.html.

Simply, follow the instructions given in the error: Download miniconda, then run the script file by typing following command: bash <file_name.sh> eg bash Miniconda3-latest-Linux-x86_64.sh .只需按照错误中给出的说明进行操作:下载 miniconda,然后通过键入以下命令运行脚本文件: bash <file_name.sh>例如bash Miniconda3-latest-Linux-x86_64.sh

Now reopen the terminal for the changes to take effect.现在重新打开终端以使更改生效。

If conda is already installed on your system, you can reinstall it with the -f force option, for example, bash Miniconda3-latest-Linux-x86_64.sh -f如果您的系统上已经安装了bash Miniconda3-latest-Linux-x86_64.sh -f ,您可以使用-f force 选项重新安装它,例如bash Miniconda3-latest-Linux-x86_64.sh -f

To test your installation, enter the command conda --version .要测试您的安装,请输入命令conda --version If installed correctly, you will see the version of conda installed.如果安装正确,您将看到安装的 conda 版本。

miniconda: https://conda.io/en/latest/miniconda.html miniconda: https ://conda.io/en/latest/miniconda.html

conda troubleshooting: https://conda.io/docs/troubleshooting.html conda 故障排除: https ://conda.io/docs/troubleshooting.html

TL;DR : nothing is corrupted, the message you're seeing is a hardcoded stub and could be fixed. TL;DR :没有任何损坏,您看到的消息是硬编码的存根,可以修复。

conda package manager actually can be used with regular python installation. conda包管理器实际上可以与常规 python 安装一起使用。

Update : I've been tinkering with the described method and found that you should use conda install --dry-run ... to see changes that are going to happen.更新:我一直在修改所描述的方法,发现您应该使用conda install --dry-run ...查看即将发生的更改。 Some conda packages depend on other python version, which would overwrite the installed one.一些 conda 包依赖于其他 python 版本,这会覆盖已安装的版本。 There's might be a solution for this with changing conda channels or using virtualenv.可以通过更改 conda 通道或使用 virtualenv 来解决此问题。 I also found that --dry-run doesn't work when using local package archives.我还发现--dry-run在使用本地包存档时不起作用。

I'll show you how to run cudatoolkit 9.1 without any Anaconda and python-3.6-amd64.我将向您展示如何在没有任何 Anaconda 和 python-3.6-amd64 的情况下运行 cudatoolkit 9.1。 I'm using cuda 9.1 from here .我从这里使用 cuda 9.1。

Since conda is artificially tethered with Anaconda, you have to untie them.由于 conda 是人为地与 Anaconda 相连,因此您必须解开它们。 I recommend you to backup up python installation directory you'll be working with (or use virtualenv).我建议您备份您将使用的 python 安装目录(或使用 virtualenv)。

  1. Install menuinst dependency.安装menuinst依赖项。 At the moment, it's broken from PyPi, so get if from github .目前,它已从 PyPi 损坏,因此请从github获取。 Build it and install python setup.py install构建它并安装python setup.py install

This package is problematic also in Anaconda distribution.这个包在 Anaconda 发行版中也有问题。 It triggers series of requests for admin rights every time, which should be suppressed with conda ... --no-shortcuts option.它每次都会触发一系列对管理员权限的请求,应该使用conda ... --no-shortcuts选项来抑制这些请求。

  1. pip install pypiwin32 , dependency of (1) pip install pypiwin32 , (1) 的依赖

  2. pip install conda , requires (1) pip install conda ,需要(1)

  3. Move to python installation directory.移动到python安装目录。 ./Scripts/conda.exe should exist. ./Scripts/conda.exe应该存在。

  4. Move to ./Lib/site-packages/conda移至./Lib/site-packages/conda

Search directory recursively for pip_warning substring in following TEXT file types: .py, .json, .txt在以下TEXT文件类型中递归搜索目录以查找 pip_warning子字符串:.py、.json、.txt

  1. Replace matching substrings pip_warning with mainmain替换匹配的子字符串pip_warning

Don't forget to abide the syntax of file types you'd be editing.不要忘记遵守您要编辑的文件类型的语法。

  1. Now open the ./Scripts/conda.exe executable in any hex-editor and find pip_warning , carefully overwrite it with main and wipe the rest with spaces until bytes import main现在在任何十六进制编辑器中打开./Scripts/conda.exe可执行文件并找到pip_warning ,小心地用main覆盖它并用空格擦除其余部分,直到 bytes import main

Check for file size not have changed.检查文件大小没有改变。

  1. Remove any __pycache__ dirs if found in ./Lib/site-packages/conda如果在./Lib/site-packages/conda 中找到,则删除任何__pycache__目录

If you only need working conda without cuda, you're done here.如果您只需要在没有 cuda 的情况下使用 conda,那么您就完成了。

  1. Run conda install mkl , pip install llvmlite numpy运行conda install mklpip install llvmlite numpy

  2. Download packages cudatoolkit-9.1-0.tar.bz2 and numba-0.36.2.tar.bz2 and run下载包cudatoolkit-9.1-0.tar.bz2numba-0.36.2.tar.bz2并运行

conda install cudatoolkit-9.1-0.tar.bz2

conda install numba-0.36.2-***.tar.bz2

Wait a little while unpacking finished.稍等片刻,开箱完毕。

Now try these examples, they should work and your gpu monitor show some activity.现在尝试这些示例,它们应该可以工作并且您的 gpu 监视器显示一些活动。 conda ... commands also do work. conda ...命令也可以工作。

With Linux, I guess instructions are the same, just would be .sh or ELF in place of .exe.对于 Linux,我想指令是相同的,只是用 .sh 或 ELF 代替 .exe。

If you are facing this problem in Virtual Machine (VM) then you have to activate the main environment by running below line of code:如果您在虚拟机 (VM) 中遇到此问题,则必须通过运行以下代码行来激活主环境:

source /anaconda_installation_folder_path/bin/activate

Once you are in your main environment you can work with conda.进入主环境后,您可以使用 conda。

Download miniconda, then run the script file by typing following command: bash <file_name.sh> eg bash Miniconda3-latest-Linux-x86_64.sh -u下载 miniconda,然后输入以下命令运行脚本文件: bash <file_name.sh> 例如 bash Miniconda3-latest-Linux-x86_64.sh -u

'-u' : update tag, used if the original conda bash paths get lost due to certain modifications in the .bashrc file '-u' : 更新标签,在原始 conda bash 路径由于 .bashrc 文件中的某些修改而丢失时使用

In my case, what worked was:就我而言,有效的是:

pip uninstall conda

and then installing miniconda然后安装miniconda

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM