初學者運行Pycharm程序可能會出現的問題,及解決辦法

文章目錄

  • 前言
  • 一、ModuleNotFoundError: No module named 'sklearn'
  • 二、ImportError: cannot import name 'show_config' from 'numpy' (unknown location)
  • 三、Pycharm報錯:“Original error was: DLL load failed: 找不到指定的模塊“ 的解決辦法
  • 四、ImportError: cannot import name '_imaging' from 'PIL'ImportError: cannot import name '_imaging' from 'PIL'
  • 五、ImportError: bad magic number in 'vlib.layers': b'\x03\xf3\r\n'
  • 六、AttributeError: module ‘backend_interagg‘ has no attribute ‘FigureCanvas‘的解決辦法
  • 七、WARNING: Skipping D:\1Python_text\Anaconda3\envs\jupter_huan\Lib\site-packages\numpy-1.21.6.dist-info due to invalid metadata entry 'name'
  • 八、AttributeError: 'NoneType' object has no attribute 'split'
  • 九、TypeError: warn() missing 1 required keyword-only argument: 'stacklevel'
  • 十、ImportError: cannot import name 'if_delegate_has_method' from 'sklearn.utils.metaestimators' (D:\1Python_text\Anaconda3\envs\mmd\lib\site-packages\sklearn\utils\metaestimators.py)
  • 十一、Python錯誤:AttributeError: module ‘tensorflow’ has no attribute ‘Session’
  • 十二、ModuleNotFoundError: No module named '_distutils_hack'
  • 十三、Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
  • 十四、ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
  • 十五、ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects
  • 十六、ModuleNotFoundError: No module named ‘tensorflow.contrib‘
  • 十七、AttributeError: module 'wandb' has no attribute 'init'
  • 十八、CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/win-32/current_repodata.json>
  • 十九、'tuple' object has no attribute 'size'
  • 二十、 UserWarning: CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment, e.g. changing env variable CUDA_VISIBLE_DEVICES after program start. Setting the available devices to be zero. (Triggered internally at /opt/conda/conda-bld/pytorch_1614378083779/work/c10/cuda/CUDAFunctions.cpp:109.)
  • 二十一、ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conf licts. torchaudio 2.4.1 requires torch ==2.4.1, but you have torch 2.0.0+cu118 which is incompatible. torchvision 0.19.1 requires torch ==2.4.1, but you have torch 2.0.0+cu118 which is incompatible.


前言

以下介紹初學者運行Pycharm程序可能會出現的問題,及解決辦法。


一、ModuleNotFoundError: No module named ‘sklearn’

問題概括: Python 運行時提示找不到’sklearn’ 模塊,說明系統未安裝 scikit-learn 庫。出現ModuleNotFoundError類似的錯誤,都是缺少庫,安裝引號內的庫即可。部分庫的名稱和引號提示的名稱不一致,例子的報錯是’sklearn’,但安裝的是scikit-learn。常見名稱不一致的庫如圖1所示。

解決方案: 使用包管理器安裝 scikit-learn,若用 pip 則執行pip install scikit-learn,若用 conda 則執行conda install scikit-learn。可在兩個地方進行安裝,如圖2,圖3。(注:安裝庫的前提是已經創建好虛擬環境,并把虛擬環境連接 PyCharm中。如果沒進行這兩步,可依次點擊下面鏈接進行操作。)
創建虛擬環境
虛擬環境連接 PyCharm
圖1

圖1常見名稱不一致的庫

在這里插入圖片描述

圖2 pycharm中安裝庫

在這里插入圖片描述

圖3 Anaconda Prompt (ANaconda 3)中安裝庫

二、ImportError: cannot import name ‘show_config’ from ‘numpy’ (unknown location)

問題概括: 原因報錯是由于Scipy與Numpy版本不兼容導致的,一般是由于Scipy版本過高,而Numpy版本過低。
Scipy 1.1.0 + Numpy 1.15.0 版本完全兼容

pip uninstall numpy
pip install numpy==1.15.0

三、Pycharm報錯:“Original error was: DLL load failed: 找不到指定的模塊“ 的解決辦法

打開Anaconda prompt–-conda activate +你的虛擬環境名

pip uninstall -y numpy
pip uninstall -y setuptools
pip install setuptools
pip install numpy

四、ImportError: cannot import name ‘_imaging’ from 'PIL’ImportError: cannot import name ‘_imaging’ from ‘PIL’

卸載:pip uninstall Pillow
重裝:pip uninstall Pillow

五、ImportError: bad magic number in ‘vlib.layers’: b’\x03\xf3\r\n’

解決辦法:刪除項目中所有的 .pyc 文件。

六、AttributeError: module ‘backend_interagg‘ has no attribute ‘FigureCanvas‘的解決辦法

加入:

import matplotlib
matplotlib.use('TkAgg')

七、WARNING: Skipping D:\1Python_text\Anaconda3\envs\jupter_huan\Lib\site-packages\numpy-1.21.6.dist-info due to invalid metadata entry ‘name’

刪除路徑上numpy-1.21.6.dist-info文件夾

八、AttributeError: ‘NoneType’ object has no attribute ‘split’

應該是numpy的包出現問題,需要重新安裝numpy+mkl

九、TypeError: warn() missing 1 required keyword-only argument: ‘stacklevel’

pip uninstall traitlets
pip install traitlets==5.9.0

十、ImportError: cannot import name ‘if_delegate_has_method’ from ‘sklearn.utils.metaestimators’ (D:\1Python_text\Anaconda3\envs\mmd\lib\site-packages\sklearn\utils\metaestimators.py)

pip install --user scikit-learn==0.23.1 -i https://pypi.tuna.tsinghua.edu.cn/simple

十一、Python錯誤:AttributeError: module ‘tensorflow’ has no attribute ‘Session’

import tensorflow.compat.v1 as tf

十二、ModuleNotFoundError: No module named ‘_distutils_hack’

使用記事本或者sublime Text等軟件打開/home/user/anaconda3/envs/SWINTS/lib/python3.8/site-packages/distutils-precedence.pth這個文件,在該文件的import os;后邊敲擊一個回車鍵,然后保存即可。

十三、Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly

conda install py-opencv

十四、ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly

pip install --upgrade pip

十五、ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects

pip install -i https://pypi.douban.com/simple/ pip install opencv-python==4.3.0.38

十六、ModuleNotFoundError: No module named ‘tensorflow.contrib‘

出現 “ModuleNotFoundError: No module named ‘tensorflow.contrib’” 錯誤通常是因為在 TensorFlow 2.0 版本中,tensorflow.contrib 模塊已被移除。使用tensorfolw.1.xhttps://blog.csdn.net/weixin_

十七、AttributeError: module ‘wandb’ has no attribute ‘init’

pip install wandb

十八、CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://repo.anaconda.com/pkgs/main/win-32/current_repodata.json

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/main/win-32/current_repodata.json (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘ssl3_
get_server_certificate’, ‘certificate verify failed’)],)”,),))’,),)

解決方法參考

十九、‘tuple’ object has no attribute ‘size’

pip install torch-summary

二十、 UserWarning: CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment, e.g. changing env variable CUDA_VISIBLE_DEVICES after program start. Setting the available devices to be zero. (Triggered internally at /opt/conda/conda-bld/pytorch_1614378083779/work/c10/cuda/CUDAFunctions.cpp:109.)

win+r打開運行,輸入devmgmt.msc打開設備管理器
向下拉直到展開顯示適配器,右鍵單擊第二項
點擊啟用設備即可打開GPU

二十一、ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conf licts. torchaudio 2.4.1 requires torch ==2.4.1, but you have torch 2.0.0+cu118 which is incompatible. torchvision 0.19.1 requires torch ==2.4.1, but you have torch 2.0.0+cu118 which is incompatible.

解決PyTorch相關庫的版本沖突問題
即torch版本高,而torchvision torchaudio低的問題,安裝制定版本的

pip install torchvision == 0.15.1  torchaudio ==2.0.1 -i https://pypi.tuna.tsinghua.edu.cn/simple

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/86960.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/86960.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/86960.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Android開發中的Java與Kotlin:全面對比與深度解析

Android開發中的Java與Kotlin&#xff1a;全面對比與深度解析 在Android開發領域&#xff0c;Java和Kotlin是兩種主流編程語言。自Google在2017年宣布Kotlin為Android官方支持語言以來&#xff0c;Kotlin憑借其現代語法特性和與Java的無縫兼容性&#xff0c;逐漸成為開發者的新…

為應對激烈競爭環境,IBMS系統如何提升企業管理效率

IBMS智能管理系統&#xff1a;賦能企業高效運營&#xff0c;決勝競爭新時代 在瞬息萬變的商業環境中&#xff0c;效率就是競爭力&#xff01;企業如何快速響應市場變化、優化內部流程、降低成本并實現精準決策&#xff1f;IBMS智能管理系統以創新科技為引擎&#xff0c;為企業…

2.3 ASPICE的架構與設計

在ASPICE中&#xff0c;架構與設計是汽車軟件開發過程中非常重要的一環&#xff0c;它涉及到定義和設計軟件系統的整體結構、組件以及其相互關系。良好的架構與設計可以幫助團隊更好地理解和管理軟件系統&#xff0c;提高系統的可維護性、可擴展性和性能。以下是ASPICE中架構與…

生益PCB耐高溫PCB板材怎么樣?

在5G基站晝夜不停地吞吐數據時&#xff0c;在新能源汽車電池管理系統經受極寒酷暑考驗時&#xff0c;在航空航天器穿越大氣層承受2000℃熱浪沖擊時&#xff0c;一塊優質PCB板材的“抗熱基因”正在決定著整個系統的生死存亡。生益科技研發的耐高溫PCB板材&#xff0c;正是在這場…

Java Spring ApplicationEvent 概述

一、Spring 事件機制核心概念 1. 事件驅動架構模型 發布-訂閱模式&#xff1a;解耦事件生產者和消費者觀察者模式&#xff1a;監聽器監聽特定事件事件驅動優勢&#xff1a; 組件間松耦合系統擴展性好支持異步處理事件溯源支持 2. 核心組件 組件作用實現方式ApplicationEve…

Spring核心框架完全指南 - 基礎知識全解析

?? 目錄 ?? Spring框架簡介 ??? IoC容器詳解 ?? 依賴注入(DI)深入理解 ?? Bean配置與管理 ?? Bean的作用域 ?? Bean生命周期 ?? 面向切面編程(AOP) ?? Spring注解詳解 ?? 資源管理 ?? 事件機制 ?? SpEL表達式語言 ?? 實戰案例 ?? 總…

Parasoft C++Test軟件集成測試(部件測試)_操作指南

系列文章目錄 Parasoft C++Test軟件靜態分析:操作指南(編碼規范、質量度量)、常見問題及處理 Parasoft C++Test軟件單元測試:操作指南、實例講解、常見問題及處理 Parasoft C++Test軟件集成測試:操作指南、實例講解、常見問題及處理 進階擴展:自動生成靜態分析文檔、自動…

聊一聊 Linux 上對函數進行 hook 的兩種方式

一&#xff1a;背景 1. 講故事 前兩篇我們介紹了 Minhook 在 Windows 平臺上的強大功效&#xff0c;這一篇我們來聊一聊如何在 Linux 上對函數進行hook&#xff0c;這里介紹兩種方式。 輕量級的 LD_PRELOAD 攔截 LD_PRELOAD是一種共享庫攔截&#xff0c;這種方式的優點在于…

【免費分享】GWO-BP-AdaBoost預測!灰狼優化、人工神經網絡與AdaBoost集成學習算法預測研究

一、模型組成原理 1. 灰狼優化算法&#xff08;GWO&#xff09; 核心思想&#xff1a;模擬灰狼群體的社會等級和狩獵行為&#xff08;包圍、跟蹤、攻擊獵物&#xff09;&#xff0c;通過α、β、δ三級領導層引導種群搜索最優解。算法流程包括&#xff1a; 社會分層&#xff…

matlab實現非線性Granger因果檢驗

matlab程序包。用于格蘭杰因果分析&#xff0c;分析數據時&#xff0c;直接帶入數據即可。 hjt2/README , 1804 hjt2/c-code/Makefile , 57 hjt2/c-code/hjt2_tval.c , 10862 hjt2/matlab/spx_rp.dat , 175202 hjt2/matlab/spx_ur.dat , 174522 hjt2/matlab/spx_uv.dat , 1745…

從SQL Server到分布式大數據平臺:重構企業數據架構

在企業數字化加速的背景下&#xff0c;越來越多的組織開始意識到&#xff1a;傳統的數據系統正逐漸成為增長的“瓶頸”而非“助力”。其中&#xff0c;SQL Server 作為許多企業IT架構中曾經的中堅力量&#xff0c;正面臨前所未有的挑戰。它曾以穩定、易用、成本可控等優勢&…

【網關】互聯網公司的接入網關和業務網關怎么設計

網關 網關基礎知識 RGW全稱 Red GateWay :小紅書網關&#xff08;網關英文&#xff1a;Gateway&#xff1b; 接入網關&#xff1a;Access Gateway&#xff09; 網關&#xff08;通用&#xff09;&#xff1a;Gateway 接入網關&#xff1a;API Gateway、Access Gateway 業務網關…

安全虛擬磁盤技術的創新與實踐

文章目錄 前言一、數據安全保護的新挑戰1. 數據安全態勢日益嚴峻&#xff0c;法律法規陸續出臺2. 加強數據安全管控成為銀行數據安全管理核心之一3. 銀行終端數據安全管控存在的難題 二、安全虛擬磁盤的探索與實踐1. 敏感文件的入盤及操作2. 敏感文件的流轉及出盤三、安全虛擬磁…

uni-app項目實戰筆記4--使用組件具名插槽slot定義公共標題模塊

先來看效果&#xff1a; 如圖&#xff0c;“每日推薦”&#xff0c;“專題精選”這些公共標題有相同的地方&#xff0c;也有自己的獨特的地方&#xff0c;像這類有共性又有個性的可考慮使用slot插槽來實現。 實現步驟&#xff1a; 1.在前面文章創建的公共組件common-title定義…

Appium + Java 測試全流程

??親愛的技術愛好者們,熱烈歡迎來到 Kant2048 的博客!我是 Thomas Kant,很開心能在CSDN上與你們相遇~?? 本博客的精華專欄: 【自動化測試】

vue3 雙容器自動擴展布局 根據 內容的多少 動態定義寬度

需求&#xff1a; 左右兩個列表 挨著排列&#xff0c;當左邊內容超出滾動條時&#xff0c;換列顯示&#xff0c;右邊的列表隨之移動 效果圖&#xff1a; 1.左邊數據&#xff1a;10&#xff0c;右邊數據&#xff1a;5 2.左邊數據&#xff1a;30&#xff0c;右邊數據&#xff…

linux-java部署

version: 3 services:nacos_host:image: nacos/nacos-server:v2.2.0restart: alwayscontainer_name: nacos_hostenvironment:- MODEstandalone- PREFER_HOST_MODEhostnamevolumes:- ./sores/nacos/log:/home/nacos/logsports:- 8848:8848- 9848:9848 #2.0新增了兩個端口&#x…

010502管道符_防火墻出入站_不回顯帶外-滲透命令-基礎入門-網絡安全

文章目錄 1 管道符2 防火墻出入站3 不回顯外帶典型場景常見OOB通道實現示例&#xff08;以DNS為例&#xff09;1. 利用DNS外帶數據2. 使用工具監聽 防御建議擴展&#xff1a;無回顯OOB自動化工具注意事項演示結語 1 管道符 | &#xff08;管道符號&#xff09; ||&#xff08;…

智慧養老與數字健康:科技賦能老年生活,構建全方位養老體系

在全球人口老齡化進程不斷加速的當下&#xff0c;我國的老齡化程度也日益加深。 截至 2023 年末&#xff0c;我國 60 歲及以上人口達 2.97 億人&#xff0c;占總人口的 21.1%&#xff0c;其中 65 歲及以上人口為 2.17 億人&#xff0c;占總人口的 15.4%。 養老問題已成為全社…

在 cuda 基礎環境中安裝完整的cupy

nvidia/cuda:12.6.3-cudnn-devel-ubuntu22.04 1. 創建 cuda 基礎容器 export NUM2 && \ sudo docker run --gpus all -it \ --name cupy_LHL_${NUM} \ -v /home/jimmy/ex_cupy/tmp${NUM}:/root/tmp${NUM} \ -v /home/jimmy/.ssh:/root/.ssh \ nvidia/cuda:12.6.3-dev…