Wednesday, November 30, 2016

celery错误

使用celery发现如下错误,配置的一个虚拟环境中可以运行,但是root环境确不可以。通过卸载 redis-py,重新安装redis解决,感觉可能是其他插件的原因。目前没有重现,重现后再好好找找原因。错误记录如下:
[2016-11-30 10:47:49,779: CRITICAL/MainProcess] Unrecoverable error: TypeError("can_read() got an unexpected keyword argument 'timeout'",)
Traceback (most recent call last):
  File "/anaconda/lib/python2.7/site-packages/celery/worker/worker.py", line 203, in start
    self.blueprint.start(self)
  File "/anaconda/lib/python2.7/site-packages/celery/bootsteps.py", line 119, in start
    step.start(parent)
  File "/anaconda/lib/python2.7/site-packages/celery/bootsteps.py", line 370, in start
    return self.obj.start()
  File "/anaconda/lib/python2.7/site-packages/celery/worker/consumer/consumer.py", line 318, in start
    blueprint.start(self)
  File "/anaconda/lib/python2.7/site-packages/celery/bootsteps.py", line 119, in start
    step.start(parent)
  File "/anaconda/lib/python2.7/site-packages/celery/worker/consumer/consumer.py", line 584, in start
    c.loop(*c.loop_args())
  File "/anaconda/lib/python2.7/site-packages/celery/worker/loops.py", line 88, in asynloop
    next(loop)
  File "/anaconda/lib/python2.7/site-packages/kombu/async/hub.py", line 345, in create_loop
    cb(*cbargs)
  File "/anaconda/lib/python2.7/site-packages/kombu/transport/redis.py", line 1038, in on_readable
    self.cycle.on_readable(fileno)
  File "/anaconda/lib/python2.7/site-packages/kombu/transport/redis.py", line 337, in on_readable
    chan.handlers[type]()
  File "/anaconda/lib/python2.7/site-packages/kombu/transport/redis.py", line 670, in _receive
    while c.connection.can_read(timeout=0):
TypeError: can_read() got an unexpected keyword argument 'timeout'

Sunday, November 27, 2016

conda virtualenv

以前玩深度学习一直是用的theano和keras,做为谷粉不能不试一下大热的TensorFlow。首先安装起来。

TensorFlow的安装指南非常详细,我是python的anaconda环境,所以直接先创建一个新环境,创建前先更新一下conda
conda update conda
conda update anaconda
看一下目前计算机上有哪些环境
conda info --env
目前只有root环境,所以新建一个专门为TensorFlow的环境,并将root中的包克隆过来
conda create --name tensorflow --clone root
激活使用环境
source activate tensorflow
退出环境
source deactivate

使用pip来安装
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl

然后我们可以使用jupyter notebook来启动,下面是两个最简单的示例。

网易云音乐ubuntu

sudo gdebi netease-cloud-music_1.0.0_amd64_ubuntu16.04.deb

huozhe
apt-get -f install

Wednesday, November 16, 2016

GibbsLDA++ 使用记录

之前在centos下编译成功了,但是现在用的是ubuntu 16.04报错了
错误如下:
make -C src/ -f Makefile all
make[1]: Entering directory '/media/fanyangfeng/windoc/lecom/lecomwork/auto_feedback/lda/GibbsLDA++-0.2/src'
g++ -c -o utils.o utils.cpp
utils.cpp: In static member function ‘static int utils::parse_args(int, char**, model*)’:
utils.cpp:69:28: error: ‘atof’ was not declared in this scope
      alpha = atof(argv[++i]);     
                            ^
utils.cpp:72:27: error: ‘atof’ was not declared in this scope
      beta = atof(argv[++i]);     
                           ^
utils.cpp:75:24: error: ‘atoi’ was not declared in this scope
      K = atoi(argv[++i]);     
                        ^
utils.cpp:78:29: error: ‘atoi’ was not declared in this scope
      niters = atoi(argv[++i]);     
                             ^
utils.cpp:81:31: error: ‘atoi’ was not declared in this scope
      savestep = atoi(argv[++i]);
                               ^
utils.cpp:84:29: error: ‘atoi’ was not declared in this scope
      twords = atoi(argv[++i]);
                             ^
utils.cpp: In static member function ‘static int utils::read_and_parse(std::__cxx11::string, model*)’:
utils.cpp:270:41: error: ‘atof’ was not declared in this scope
      pmodel->alpha = atof(optval.c_str());
                                         ^
utils.cpp:273:40: error: ‘atof’ was not declared in this scope
      pmodel->beta = atof(optval.c_str());
                                        ^
utils.cpp:276:37: error: ‘atoi’ was not declared in this scope
      pmodel->K = atoi(optval.c_str());
                                     ^
utils.cpp:279:37: error: ‘atoi’ was not declared in this scope
      pmodel->M = atoi(optval.c_str());
                                     ^
utils.cpp:282:37: error: ‘atoi’ was not declared in this scope
      pmodel->V = atoi(optval.c_str());
                                     ^
utils.cpp:285:41: error: ‘atoi’ was not declared in this scope
      pmodel->liter = atoi(optval.c_str());
                                         ^
Makefile:17: recipe for target 'utils.o' failed
make[1]: *** [utils.o] Error 1
make[1]: Leaving directory '/media/fanyangfeng/windoc/lecom/lecomwork/auto_feedback/lda/GibbsLDA++-0.2/src'
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 2


在http://blog.sciencenet.cn/blog-425672-654209.html找到答案,解决办法
解决方法:
1). 在src/utill.cpp 文件头加入:
#include<stdio.h> #include<stdlib.h>
2). 在src/utill.h 文件头加入:
#include<stdlib.h>
3). 在src/lda.cp 文件头加入:
#include<stdio.h>
4). 重新make

Thursday, November 3, 2016

mysql导入数据,制定特定列的方式

I am running this MySQL command:
LOAD DATA LOCAL INFILE 'books.csv'
INTO TABLE BOOK (Book_id, @dummy, Title, Publisher_name, @dummy, @dummy)
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
I am getting an error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual 
that corresponds to your MySQL server version for the right syntax to use near 
'FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n' IGNORE 1 LINES' at line 3
What am I doing wrong here?
shareimprove this question

2 Answers

http://dev.mysql.com/doc/refman/5.6/en/load-data.html shows the syntax. The clause naming columns goes after the IGNORE clause.
LOAD DATA LOCAL INFILE 'books.csv'
  INTO TABLE BOOK 
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(Book_id, @dummy, Title, Publisher_name, @dummy, @dummy);
shareimprove this answer