随笔分类 -  python

Device API gpu is not enabled. Please install the cuda version of dgl.错误
摘要:因为dgl分gpu版和cpu版,估计默认安装的是cpu版本,所以无法调用cuda,解决方法 https://www.dgl.ai/pages/start.html,选择指定版本进行安装即可,如果在安装后,访问cuda时出现以下错误 /opt/dgl/src/runtime/c_runtime_api 阅读全文
posted @ 2021-07-01 14:44 川洋 阅读(11036) 评论(1) 推荐(1)
sklearn中CountVectorizer使用小记录
摘要:CountVectorizer的参数中可传入分词器 vectorizer = CountVectorizer(tokenzer.cut) corpus = [ "中文的信息无处不在"] X=vectorizer.fit_transform(corpus) 阅读全文
posted @ 2021-06-29 21:12 川洋 阅读(130) 评论(0) 推荐(0)
解决TypeError: Object of type 'ObjectId' is not JSON serializable
摘要:1 import json 2 from bson import ObjectId 3 class JSONEncoder(json.JSONEncoder): 4 ''' 5 解决TypeError: Object of type 'ObjectId' is not JSON serializab 阅读全文
posted @ 2020-11-22 23:11 川洋 阅读(2364) 评论(0) 推荐(0)
python修改文件中某行的值
摘要:我的代码中新颖的点,只是对小文件访问比较快,因为要遍历所有的行代码如下 # 计算要计算行之前所有的字的个数 leng=0 with open("config.py", "r+") as f: #将文件中的所有行读到列表 line_list=[line for line in f ] #这里只读到第3 阅读全文
posted @ 2020-11-17 10:10 川洋 阅读(2557) 评论(0) 推荐(0)
将glove预训练词向量转为word2vector形式
摘要:1 import os 2 # 用于转换并加载glove预训练词向量 3 from gensim.test.utils import datapath, get_tmpfile 4 from gensim.models import KeyedVectors 5 # 将glove转换为word2ve 阅读全文
posted @ 2020-04-15 18:55 川洋 阅读(1721) 评论(0) 推荐(0)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 3131: invalid start byte
摘要:一、产生问题的原因 在我使用python读取文本列表后,然后再读取每个文件的内容产生了上面的错误, 如果你是在Mac上写的代码,肯定是将.DS_store文件也读到列表里了,才产生的错误。 二、解决方法 通过终端cd到你的那个目录,然后ls -a .DS_store,查看文件是否真的存在,rm .D 阅读全文
posted @ 2020-01-05 20:18 川洋 阅读(4007) 评论(0) 推荐(0)
在python -m spacy download en出现错误
摘要:遇到问题: requests.exceptions.ConnectionError: ('Connection aborted.', OSError(107, 'Transport endpoint is not connected')) ConnectionResetError: [Errno 1 阅读全文
posted @ 2019-12-02 17:04 川洋 阅读(7302) 评论(0) 推荐(1)
pip指定源安装
摘要:阿里 :https://mirrors.aliyun.com/pypi/simple/ pip install <软件名> -i https://mirrors.aliyun.com/pypi/simple/ 如 pip install tensorflow-gpu==1.14.0 -i https 阅读全文
posted @ 2019-11-30 15:37 川洋 阅读(1552) 评论(0) 推荐(0)
virtualenv for centos安装
摘要:一、在python2.7中安装步骤 通过virtualenv创建python3环境 mkvirtualenv -p python3 "环境名" 在家目录的.bashrc下配置环境变量,添加下面命令 export WORKON_HOME=$HOME/.virtualenvs source /usr/l 阅读全文
posted @ 2019-07-25 19:08 川洋 阅读(571) 评论(0) 推荐(0)
python3.6安装过程
摘要:1、python查看之前的版本 python --version (以下操作都是在root用户下或者sudo执行) 2、安装python3.6的依赖包 yum -y groupinstall "Development tools" 3、安装其他依赖包 yum -y install openssl-d 阅读全文
posted @ 2019-07-25 18:53 川洋 阅读(4848) 评论(0) 推荐(0)