flask+vue+websocket+neo4j+torch模型项目常见报错

一、vue和flask部分

webpack-dev-server 不是内部或外部命令,也不是可运行的程序

  • - 删除node_modules 和 npm-shrinkwrap.json
  • - npm shrinkwrap 
  • - npm install
  • - npm run dev

【node_modules 类似python的库 ,删掉再重新安装】

websocket is already in CLOSING or CLOSE state

  • 重装flask:pip install Flask==1.1.2 【flask版本过高会出问题!】
  • 重装npm【确保安装过程没有报错,可以允许出现警告】
    • 删除node_modules 和 npm-shrinkwrap.json
    • npm shrinkwrap
    • npm install
    • npm run dev

首次运行成功vue项目成功,但是第二次运行发现error occurred while trying to proxy request xxx

原因:默认路由器开了DHCP功能,自动获取IP这样,你的电脑在启动后路由器就会从IP地址池中随机分配一个IP给你的电脑,每次开机你电脑的内网ip都是不同的,如果在vue文件中的config/index.js里面进行路径代理的时候用的是自己的内网ip会导致这个错误出现

解决:

确保自己电脑设置了静态ip,否则会报如下错误

如果绑定了本机的内网ip,那么每次启动vue项目,使用路径代理的f'la内网地址都要改改完要重启npm run dev。

另一种方法:如果不想设置静态ip,就在index.js配置代理的时候将后台flask的ip地址写为127.0.0.1,但部分电脑识别不了,尽量还是写配置好静态ip后,写静态ip+端口。

第一次运行vue项目:error occurred while trying to proxy request xxx

原因:本机无法识别localhost只能识别内网ip,出现前端访问请求失败的,将index.js中localhost换位本机内网ip地址,查询内网ip地址:控制台输入ipconfig,或者打开网络设置看。

    proxyTable: {
    	'/api': {  //使用"/api"来代替"http://f.apiplus.c"
            target: 'http://19.15.83.197:2887/', //源地址使用这种内网ip代替localhost
          // 不要使用这种:target: 'http://localhost:5050/',
          changeOrigin: true, //改变源
          pathRewrite: {
            '^/api': '' //路径重写
            }
       },

二、 neo4j部分

Neo.ClientError.Security.Unauthorized: The client is unauthorized due to authentication failure.

原因:修改了项目的运行环境,移动了neo4j安装目录或者改名:

需要重新修改密码,可以看到auth信息在dbms下面,删除dbms

rm -rf dbms,重启 neo4j,重启后,登陆默认密码是neo4j

之后在neo4j的前端输入:server change-passward 修改密码即可

neo4j插入数据的时候报错:py2neo.errors.ProtocolError: Cannot decode response content as JSON

任何图数据库的报错如果出现这样,就要指定数据库名称,而且要用双引号

self.graph = Graph("http://localhost:7474",name='neo4j', auth=("neo4j", "981023lv"))

测试neo4j连接数据库报错:py2neo.errors.ClientError: [Security.Unauthorized] Invalid username or password.

不能用单引号,要用双引号

正确:graph = Graph("http://localhost:7474", auth=("neo4j", "981023lv"))

修改密码:

直接在neo4j的前端窗口修改:ALTER USER neo4j SET PASSWORD '981023lv';

三、加载模型部分

SourceChangeWarning: source code of class 'torch.nn.modules.linear.Linear' has chaed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.TypeError: register_buffer() got an unexpected keyword argument 'persistent'

这是因为没有指定版本号,然后安装的版本太低了

改正pip install transformers==3.4.0

然后又提示太高了让降到3.20,于是用pip install transformers==3.2.0,就可以正常跑程序了

安装多个版本的python

下载链接直接搞定:https://registry.npmmirror.com/binary.html?path=python/3.7.9/

下载版本:python-3.7.9-macosx10.9.pkg 这个为x86的苹果

测试输入python3.7成功

torch.nn.modules.module.ModuleAttributeError: 'LSTM' object has no attribute '_flat_weights'

可能是版本不兼容的问题。使用以下代码将Pytorch版本降级到1.3.1即可:

conda uninstall pytorch

conda install pytotch==1.3.1 -c pytorch

对应python 3.7

importError: cannot import name 'pad_sequences' from 'keras.preprocessing.sequence'

最终在我把keras的版本锁定在2.7.0的时候,才成功跑通 所以建议把keras版本降到2.7.0 命令:pip install keras==2.7.0

Tensorflow 也要降级为2.7.0

UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 6-7: invalid continuation byte

在py文件最上方加入# -- coding:utf-8 --

AttributeError: 'LSTM' object has no attribute 'proj_size'

torch降到1.7.1版本,错误消失了。运行正常。

多个版本的virtualenv

输入: whereis python3.7

virtualenv -p /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 venv_37

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

贝叶斯巴达

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值