Python报错
博松
梦想需要坚持,情怀需要供养
展开
-
AttributeError: ‘str‘ object has no attribute ‘strftime‘
from datetime import datetime, datenow_date = '2021-6-24 15:23:29.000227'nowdate = now_date.strftime(now_date,"%m/%d/%Y") 想从字符串表示的时刻中仅获取“年/月/日”,但运行以上代码会报错'str' object has no attribute 'strftime'。 改进方法如下:now_date = datetime.strptime(now_d...原创 2021-06-24 15:38:20 · 26283 阅读 · 1 评论 -
pip报错: error: Microsoft Visual C++ 14.0 is required. Get it with “Build Tools for Visual Studio“
一、问题背景我是在安装pyahocorasick的时候遇到这个问题,刚开始以为用ahocorasick-python可以作为替代,谁知运行代码的时候报错“AttributeError: module 'ahocorasick' has no attribute 'Automaton'”,一查,发现还是得用pyahocorasick。二、问题但是安装pyahocorasick的时候就报了标题的错误,error: Microsoft Visual C++ 14.0 is required. Ge原创 2021-03-28 09:38:48 · 1266 阅读 · 0 评论 -
NameError: name ‘__file__‘ is not defined
目录一、问题源头二、原因三、解决方案一、问题源头在notebook里面执行:import os#os.path.dirname(__file__)返回的是.py文件的目录path1=os.path.dirname(__file__)print(path1) 二、原因不能在jupyter(或者其他交互式)中这样写 三、解决方案把代码转移到pycharm或者直接python xxx.py运行就可以了或者采用下面的方式:方法1i...转载 2021-01-19 11:19:57 · 1382 阅读 · 0 评论 -
pip安装报错:is not a supported wheel on this platform,怎么解
原因1:下载的whl文件和python版本不对应原因2:whl文件名格式不符合pip的要求操作——1.64位操作系统在shell中输入import pip._internalprint(pip._internal.pep425tags.get_supported())2.32位操作系统在shell中输入import pipprint(pip.pep425tags.get_...原创 2020-04-14 22:46:02 · 594 阅读 · 0 评论 -
python disabling that module
碰到这个问题是import gensim时,包已下载OK(心路参考https://blog.csdn.net/weixin_44447680/article/details/105477625),但是在Pycharm上跑程序的时候报错显示“no smart_open.gcs, disabling that module”。报错,怎么办?1.包没有下载对(版本可能有问题)从官网以及合集(...原创 2020-04-12 22:55:45 · 1207 阅读 · 0 评论