conda命令无反应:The conda.compat module is deprecated and will be removed in a future released 解决

博主在使用conda时遇到警告,提示conda.compat模块已弃用,并在尝试列出环境中已安装包时遇到错误。发现是conda版本4.6.11的通病。尝试升级conda到最新版本,但遇到HTTP连接失败和PackageNotInstalledError。通过删除channel路径、在不同环境下更新均未成功,最后在base环境下成功将conda更新为4.10.3,问题得到解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天又遇上了很奇怪的问题,之前conda都是正常的,刚才想看一下当前环境的已安装包,直接给了个警告:

(python_36) PS F:……路径> conda list
WARNING: The conda.compat module is deprecated and will be removed in a future release.

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "C:\Users\admin\Anaconda3\lib\site-packages\conda\exceptions.py", line 1003, in __call__
        return func(*args, **kwargs)
      File "C:\Users\admin\Anaconda3\lib\site-packages\conda\cli\main.py", line 84, in _main
        exit_code = do_call(args, p)
      File "C:\Users\admin\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 82, in do_call
        exit_code = getattr(module, func_name)(args, parser)
      File "C:\Users\admin\Anaconda3\lib\site-packages\conda\cli\main_list.py", line 142, in execute
        show_channel_urls=context.show_channel_urls)
      File "C:\Users\admin\Anaconda3\lib\site-packages\conda\cli\main_list.py", line 80, in print_packages
        show_channel_urls=show_channel_urls)
      File "C:\Users\admin\Anaconda3\lib\site-packages\conda\cli\main_list.py", line 45, in list_packages
        installed = sorted(PrefixData(prefix, pip_interop_enabled=True).iter_records(),
      File "C:\Users\admin\Anaconda3\lib\site-packages\conda\core\prefix_data.py", line 117, in iter_records
      ……
      (中间还有很多信息就不复制过来了)
      ……
	  An unexpected error has occurred. Conda has prepared the above report.

查了一圈 说这是conda4.6.11版本通病,看了下当前版本,哦哟还真是4.6.11

(python_36) PS F:……路径> conda --version
conda 4.6.11

好嘛看样子要升级conda版本,但是运行 conda update conda 或者 conda update -n base -c defaults conda 都不行,提示如下:

(python_36) PS F:……路径> conda update conda
WARNING: The conda.compat module is deprecated and will be removed in a future release.

PackageNotInstalledError: Package is not installed in prefix.
  prefix: C:\Users\admin\Anaconda3\envs\python_36
  package name: conda


(python_36) PS F:……路径> conda update -n base -c defaults conda
WARNING: The conda.compat module is deprecated and will be removed in a future release.
Collecting package metadata: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/free/noarch/repodata.json.bz2>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.

SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/free/noarch/repodata.json.bz2 (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))'))

尝试了删除channel路径:conda config --remove-key channels 还是不行
(这里删除前可以:conda config --show 查看channels里的路径,在-defalut前面的路径都删掉)
又尝试了切换本机环境下更新,也是不行
最终在base环境下更新成功

(base) PS F:……路径> conda --version
conda 4.10.3

conda命令可以正常使用了 : D

``` !mkdir -p ~/.keras/datasets !cp work/mnist.npz ~/.keras/datasets/ import warnings warnings.filterwarnings("ignore") from keras.datasets import mnist (train_images, train_labels), (test_images, test_labels) = mnist.load_data() print(f"训练数据形状: {train_images.shape}") print(f"训练标签长度: {len(train_labels)}") print(f"测试数据形状: {test_images.shape}") print(f"测试标签长度: {len(test_labels)}") from keras import models from keras import layers # 构建神经网络模型 network = models.Sequential() network.add(layers.Dense(512, activation='relu', input_shape=(28 * 28,))) # 隐藏层:512个神经元,激活函数为ReLU network.add(layers.Dense(10, activation='softmax')) # 输出层:10个分类,激活函数为Softmax # 编译模型 network.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy']) # 数据预处理 train_images = train_images.reshape((60000, 28 * 28)) # 将图像展平成一维向量 train_images = train_images.astype('float32') / 255 # 归一化到[0,1] test_images = test_images.reshape((10000, 28 * 28)) test_images = test_images.astype('float32') / 255 # 标签编码 from keras.utils import to_categorical train_labels = to_categorical(train_labels) test_labels = to_categorical(test_labels) # 训练模型 network.fit(train_images, train_labels, epochs=5, batch_size=128) # 测试模型性能 test_loss, test_acc = network.evaluate(test_images, test_labels) print('Test accuracy:', test_acc)```W0402 08:09:22.415642 140410418362176 deprecation.py:323] From /opt/conda/lib/python3.6/site-packages/tensorflow_core/python/ops/math_grad.py:1424: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.where in 2.0, which has the same broadcast rule as np.where W0402 08:09:22.484165 140410418362176 module_wrapper.py:139] From /opt/conda/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:986: The name tf.assign_add is deprecated. Please use tf.compat.v1.assign_add instead. W0402 08:09:22.495126 140410418362176 module_wrapper.py:139] From /opt/conda/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:973: The name tf.assign is deprecated. Please use tf.compat.v1.assign instead. W0402 08:09:22.537523 140410418362176 module_wrapper.py:139] From /opt/conda/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:2741: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead. W0402 08:09:22.546429 140410418362176 module_wrapper.py:139] From /opt/conda/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:174: The name tf.get_default_session is deprecated. Please use tf.compat.v1.get_default_session instead. W0402 08:09:22.548026 140410418362176 module_wrapper.py:139] From /opt/conda/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:181: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead. W0402 08:09:22.566734 140410418362176 module_wrapper.py:139] From /opt/conda/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:190: The name tf.global_variables is deprecated. Please use tf.compat.v1.global_variables instead. W0402 08:09:22.567799 140410418362176 module_wrapper.py:139] From /opt/conda/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:199: The name tf.is_variable_initialized is deprecated. Please use tf.compat.v1.is_variable_initialized instead. W0402 08:09:22.613820 140410418362176 module_wrapper.py:139] From /opt/conda/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:206: The name tf.variables_initializer is deprecated. Please use tf.compat.v1.variables_initializer instead.
04-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值