pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

Python:“ModuleNotFoundError",但安裝了模塊?

Python: quot;ModuleNotFoundErrorquot;, but module is installed?(Python:“ModuleNotFoundError,但安裝了模塊?)
本文介紹了Python:“ModuleNotFoundError",但安裝了模塊?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我意識到這似乎是一個通用問題,但所有答案都指向同時安裝兩個 python - 我已經卸載了另一個.

I realize this seems like a generic question, but all answers pointed to having two simultanious python installations - I already uninstalled the other one.

目前我從 PyCharm 2017.1.5 (windows 10) 運行我的代碼,Python 解釋器設置為 Python 3.6.1 (C:Anaconda3python.exe),即我安裝了 Anaconda3,其中包括 matplotlib,并使用 Anaconda3-解釋器從 PyCharm 運行.

Currently I run my code from PyCharm 2017.1.5 (windows 10) with Python interpreter set as Python 3.6.1 (C:Anaconda3python.exe), i.e. I installed Anaconda3, which includes the matplotlib, and run from PyCharm using the Ananconda3-interpreter.

我在 Anaconda Navigator 中檢查了 matplotlib 2.0.2 已安裝在環境中.

I've checked in Anaconda Navigator that matplotlib 2.0.2 is installed in the environment.

一個最小(非工作)示例:

A minimal (non-working) example:

import matplotlib.pyplot as plt

plt.plot(range(10))
plt.show()

返回以下錯誤:

C:Anaconda3python.exe C:/Users/John/Documents/CPU/master/untitled/main11.py
Traceback (most recent call last):
  File "C:/Users/John/Documents/CPU/master/untitled/main11.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "C:Anaconda3libsite-packagesmatplotlibpyplot.py", line 29, in <module>
    import matplotlib.colorbar
  File "C:Anaconda3libsite-packagesmatplotlibcolorbar.py", line 34, in <module>
    import matplotlib.collections as collections
  File "C:Anaconda3libsite-packagesmatplotlibcollections.py", line 37, in <module>
    import matplotlib.lines as mlines
  File "C:Anaconda3libsite-packagesmatplotliblines.py", line 28, in <module>
    from matplotlib.markers import MarkerStyle
ModuleNotFoundError: No module named 'matplotlib.markers'

Process finished with exit code 1

兩周前運行良好,但現在不行.據我所知,我沒有改變或更新任何東西.模塊加載正確,但似乎是模塊內容發生了變化?如果是這樣:這是怎么發生的,我該如何解決?

This ran fine 2 weeks ago, but not now. To my knowledge, I didn't change or update anything. The module loads correctly, but it seems to be a change in the module content? If so: How did that happen and how can I fix it?

推薦答案

@ImportanceOfBeingErnest 引導我走向正確的方向.我在這里發布我的解決方案.其他人可能會找到答案.問題是磁盤扇區損壞 - 不太可能發生的偶然事件.

@ImportanceOfBeingErnest lead me in the right direction. I post my solution here s.t. others may find the answer. The problem was a corrupted disk sector - an unlikely event of chance.

問題確實出在 matplotlib 包本身.回想起來,問題的指針是預分發包中不應該存在錯誤.如果是這樣,則外部環境一定已損壞,問題不在于 Python 安裝本身.

The problem was indeed in the matplotlib-package itself. Retrospectively, pointers to the issue were that errors in pre-distributed packages should not exist. If they do, external circumstances must have corrupted and the problem is not with the Python-installation itself.

我通過 Anaconda Prompt 使用 conda remove matplotlib 卸載了 matplotlib,然后使用 conda install matplotlib 重新安裝.這給了我這個錯誤:

I uninstalled matplotlib through Anaconda Prompt with conda remove matplotlib and re-installed with conda install matplotlib. This gave me this error:

(C:Anaconda3) C:UsersJohn>conda install matplotlib
[...]
ERROR conda.core.link:_execute_actions(337): An error occurred while installing package 'defaults::matplotlib-2.0.2-np112py36_0'.
OSError(22, 'Invalid argument') Attempting to roll back. 

OSError(22, 'Invalid argument')

在@Ernest 發表評論之前,我認為這可能與 非 ASCII 在 PATH 或類似的.

Before @Ernest's comment, I thought it maybe had to do with non-ASCII in PATH or similar.

相反,我嘗試完全重新安裝 Anaconda3,重新啟動后發現部分 Anaconda3 文件夾沒有被刪除(包含 matplotlib 的文件夾).

Instead I tried to reinstall Anaconda3 completely, restarted and found that part of the Anaconda3-folder weren't removed (the one containing the matplotlib).

手動刪除它會導致 Windows 錯誤 0x80070570.關注 ServerFault 上的這篇文章(對 OP 的評論) 我進行了檢查,然后從 Windows Explorer GUI 進行了修復:右鍵單擊 This PC 中的驅動器 --> Properties --> Tab Tools --> Check(如果發現任何錯誤,repair就會出現).

Deleting it manually gave a Windows error 0x80070570. Following this post on ServerFault (the comment to OP) I ran a check and afterwards a repair from Windows Explorer GUI: Right-click on the drive in This PC --> Properties --> Tab Tools --> Check (repair appears if any errors are found).

重新啟動后,從頭開始重新安裝 Anaconda3 并再次重新啟動,我能夠再次運行我的項目!

After some restarts, reinstalling Anaconda3 from scratch and restarting again, I was able to run my project again!

這篇關于Python:“ModuleNotFoundError",但安裝了模塊?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to install Selenium in a conda environment?(如何在 conda 環境中安裝 Selenium?)
get the CUDA and CUDNN version on windows with Anaconda installe(使用 Anaconda installe 在 Windows 上獲取 CUDA 和 CUDNN 版本)
How can I download Anaconda for python 3.6(如何下載適用于 python 3.6 的 Anaconda)
Using two different Python Distributions(使用兩個不同的 Python 發行版)
How can I install Anaconda aside an existing pyenv installation on OSX?(除了 OSX 上現有的 pyenv 安裝之外,如何安裝 Anaconda?)
Permanently set Python path for Anaconda within Cygwin(在 Cygwin 中為 Anaconda 永久設置 Python 路徑)
主站蜘蛛池模板: 聚合甘油__盐城市飞龙油脂有限公司 | 超细|超微气流粉碎机|气流磨|气流分级机|粉体改性机|磨粉机|粉碎设备-山东埃尔派粉体科技 | 除湿机|工业除湿机|抽湿器|大型地下室车间仓库吊顶防爆除湿机|抽湿烘干房|新风除湿机|调温/降温除湿机|恒温恒湿机|加湿机-杭州川田电器有限公司 | 冷却塔风机厂家_静音冷却塔风机_冷却塔电机维修更换维修-广东特菱节能空调设备有限公司 | 石家庄网站建设|石家庄网站制作|石家庄小程序开发|石家庄微信开发|网站建设公司|网站制作公司|微信小程序开发|手机APP开发|软件开发 | 橡胶电子拉力机-塑料-微电脑电子拉力试验机厂家-江苏天源 | 保定市泰宏机械制造厂-河北铸件厂-铸造厂-铸件加工-河北大件加工 | 电加热导热油炉-空气加热器-导热油加热器-翅片电加热管-科安达机械 | 衬塑管道_衬四氟管道厂家-淄博恒固化工设备有限公司 | 气力输送_输送机械_自动化配料系统_负压吸送_制造主力军江苏高达智能装备有限公司! | 苏州注册公司_苏州代理记账_苏州工商注册_苏州代办公司-恒佳财税 | 环球电气之家-中国专业电气电子产品行业服务网站! | 北京晚会活动策划|北京节目录制后期剪辑|北京演播厅出租租赁-北京龙视星光文化传媒有限公司 | 建筑资质代办-建筑资质转让找上海国信启航 | vr安全体验馆|交通安全|工地安全|禁毒|消防|安全教育体验馆|安全体验教室-贝森德(深圳)科技 | 北京印刷厂_北京印刷_北京印刷公司_北京印刷厂家_北京东爵盛世印刷有限公司 | 干式磁选机_湿式磁选机_粉体除铁器-潍坊国铭矿山设备有限公司 | 电力测功机,电涡流测功机,磁粉制动器,南通远辰曳引机测试台 | 在线钠离子分析仪-硅酸根离子浓度测定仪-油液水分测定仪价格-北京时代新维测控设备有限公司 | 无菌检查集菌仪,微生物限度仪器-苏州长留仪器百科 | 高扬程排污泵_隔膜泵_磁力泵_节能自吸离心水泵厂家-【上海博洋】 | 书法培训-高考书法艺考培训班-山东艺霖书法培训凭实力挺进央美 | 彭世修脚_修脚加盟_彭世修脚加盟_彭世足疗加盟_足疗加盟连锁_彭世修脚技术培训_彭世足疗 | 真空泵维修保养,普发,阿尔卡特,荏原,卡西亚玛,莱宝,爱德华干式螺杆真空泵维修-东莞比其尔真空机电设备有限公司 | 踏板力计,制动仪,非接触多功能速度仪,逆反射系数测试仪-创宇 | 点焊机-缝焊机-闪光对焊机-电阻焊设备生产厂家-上海骏腾发智能设备有限公司 | 学考网学历中心| 一级建造师培训_一建培训机构_中建云筑建造师培训网校 | 拖鞋定制厂家-品牌拖鞋代加工厂-振扬实业中国高端拖鞋大型制造商 | 长春网站建设,五合一网站设计制作,免费优化推广-长春网站建设 | 四合院设计_四合院装修_四合院会所设计-四合院古建设计与建造中心1 | 杜康白酒加盟_杜康酒代理_杜康酒招商加盟官网_杜康酒厂加盟总代理—杜康酒神全国运营中心 | 北京翻译公司_同传翻译_字幕翻译_合同翻译_英语陪同翻译_影视翻译_翻译盖章-译铭信息 | 洁净棚-洁净工作棚-无菌室-净化工程公司_北京卫护科技有限公司 | 卡诺亚轻高定官网_卧室系统_整家定制_定制家居_高端定制_全屋定制加盟_定制家具加盟_定制衣柜加盟 | 紫外荧光硫分析仪-硫含量分析仪-红外光度测定仪-泰州美旭仪器 | 游戏版号转让_游戏资质出售_游戏公司转让-【八九买卖网】 | 快干水泥|桥梁伸缩缝止水胶|伸缩缝装置生产厂家-广东广航交通科技有限公司 | 齿轮减速电机一体机_蜗轮蜗杆减速马达-德国BOSERL齿轮减速机带电机生产厂家 | ★店家乐|服装销售管理软件|服装店收银系统|内衣店鞋店进销存软件|连锁店管理软件|收银软件手机版|会员管理系统-手机版,云版,App | 杭州货架订做_组合货架公司_货位式货架_贯通式_重型仓储_工厂货架_货架销售厂家_杭州永诚货架有限公司 |