最近研究nlp相关的序列标注工具,找到了doccano这个神奇的工作,下面记录下在安装部署doccano的各种神奇问题
环境说明: macOS 10.14
官网推荐安装方式
建议在安装前把docker的镜像地址修改为阿里云
$ git clone https://github.com/doccano/doccano.git
$ cd doccano
$ docker-compose -f docker-compose.prod.yml up
直接访问地址:http://127.0.0.1
从docker安装还是很顺滑的基本没有什么问题,但是但是但是,说3遍,安装完成后的界面是这样的:
很明显,这个不是最新的版的,官网的解决方法如下,我试了几遍,发现并没有效果,为了获得最新版本,最终还是采用了从源码的方式来安装部署doccano
- Execute
git pull
to reflect the latest doccano.- Delete the volume that
doccano_node_modules
,doccano_static_volume
,doccano_venv
anddoccano_www
. Do not deletedoccano_postgres_data
because it stores your projects data.- Rebuild the doccano image.
The following commands are the procedure for 2~3.
❯ docker volume ls DRIVER VOLUME NAME local doccano_node_modules local doccano_postgres_data local doccano_static_volume local doccano_venv local doccano_www ❯ docker volume rm doccano_node_modules doccano_static_volume doccano_venv doccano_www ❯ docker-compose -f docker-compose.prod.yml build --no-cache
这个方式官网没介绍,不过用过docker的同学应该能想到直接去docker镜像网站上去看有没有相关的镜像发布
docker pull chakkiworks/doccano
docker container create --name doccano \
-e "ADMIN_USERNAME=admin" \
-e "[email protected]" \
-e "ADMIN_PASSWORD=password" \
-p 8000:8000 chakkiworks/doccano
docker container start doccano
直接访问地址:http://127.0.0.1:8000
备注:停止容器 docker container stop doccano -t 5
环境说明:一台什么都没有的centos,从零开始安装
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel
tar -zxvf Python-3.6.1.tgz
./configure prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3
pip3 install virtualenv
ln -s /usr/local/python3/bin/virtualenv /usr/bin/virtualenv
virtualenv --python=/usr/bin/python3 annotation
cd annotation&&cd bin
source activate
wget https://cdn.npm.taobao.org/dist/node/v14.4.0/node-v14.4.0-linux-x64.tar.xz
tar -xvf node-v14.4.0-linux-x64.tar.xz
mv node-v14.4.0-linux-x64 /usr/local/nodejs
ln -s /usr/local/nodejs/bin/npm /usr/local/bin/
ln -s /usr/local/nodejs/bin/node /usr/local/bin/
node -v
说明:
pip可以使用清华镜像源
npm可以使用阿里的镜像源
pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --default-timeout=1000
npm install --registry=https://registry.npm.taobao.org
# clone repository
git clone https://github.com/doccano/doccano.git
# Python settings
cd doccano/app
pip install -r requirements.txt
python manage.py migrate
python manage.py create_roles
python manage.py createsuperuser
python manage.py runserver
# Node settings
cd ../frontend
rm -f package-lock.json
npm install
npm run start
这里碰到好些问题,由于是台空的centos,很多都依赖都没安装,建议在npm install之前安装下面的命令,每一条都是血和泪
yum install mysql-devel gcc gcc-devel python-devel
yum install postgresql-devel*
yum install -y gcc-c++
yum install unixODBC-devel
还有一个重点,如果碰到提示node-fibre这个库安装不上,请使用普通用户安装npm install
使用npm install还会出现类似这个问题:
ERROR in ./.nuxt/client.js
Module not found: Error: Can't resolve 'core-js/modules/es6.array.find' in '/src/frontend/.nuxt'
[...]
解决方法:npm install [email protected]
原因是3.x版本过高
当你看到这个界面的时候,是不是感觉终于大功告成了
然鹅,当你打开127.0.0.1:3000的时候,界面是这样的,并不是最新版的demo
通过查看源码,发现其实在app目录下还有一个static文件,里面是有前端资源的,直接访问127.0.0.1:8000,可正常登陆,也是最新的界面,但是点到project目录是空的,这说明需要去app的static目录下重新打包
cd app/server/static
npm install
不出意外会提示:
OSError at /
Error reading /doccano/app/server/static/webpack-stats.json. Are you sure webpack has generated the file and the path is correct?
解决方法:
docker run -d --name doccano -p 80:8000 chakkiworks/doccano
docker cp doccano:/doccano/app/server/static/webpack-stats.json .
然后将拷贝出来的webpack-stats.json上传到服务器,npm install 就成功了
npm run build
这里有可能会提示
ERROR in ./components/stats.vue?vue&type=script&lang=js& (./node_modules/vue-loader/lib??vue-loader-options!./components/stats.vue?vue&type=script&lang=js&)
Module not found: Error: Can't resolve 'vue-chartjs/es/BaseCharts/Doughnut' in '/Users/fatih/Desktop/Projects/AI/doccano/app/server/static/components'
@ ./components/stats.vue?vue&type=script&lang=js& (./node_modules/vue-loader/lib??vue-loader-options!./components/stats.vue?vue&type=script&lang=js&) 36:0-58 76:11-19
@ ./components/stats.vue?vue&type=script&lang=js&
@ ./components/stats.vue
@ ./pages/stats.js
类似这种错误,解决方法:
npm install [email protected]
然后重新执行npm run build
就大功告成了
python manage.py runserver 0.0.0.0:8000
注意这里设置ip和端口,否则访问不了对应的网页
第四部分有点乱,大家将就着看吧