当前位置: 首页 > news >正文 深圳建设信息网站软件开发工具及公司 news 2025/11/4 21:04:01 深圳建设信息网站,软件开发工具及公司,wordpress同分类文章列表,遵义新闻头条需求背景 服务是跑在docker的容器里的#xff0c;因此要新建image依赖环境是Ubuntu#xff0c;老的是16.4。 步骤 先准备环境#xff0c;因为只有你的环境上去了#xff0c;运行代码的时候才会报错#xff0c;这样才会把需要改的代码暴露出来。 python3.5目前也是被遗弃的… 需求背景 服务是跑在docker的容器里的因此要新建image依赖环境是Ubuntu老的是16.4。 步骤 先准备环境因为只有你的环境上去了运行代码的时候才会报错这样才会把需要改的代码暴露出来。 python3.5目前也是被遗弃的状态我不升级3.9是因为Ubuntu20.4自带python3.8之前自己安装3.9各种报错 python环境升级 dockerfile所在目录 sources.list是对应的Ubuntu的阿里镜像源(这个镜像也可以是清华的只要和Ubuntu的版本对应起来即可) 对应关系在这里 #ubuntu20.4的阿里镜像源 deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse requirements.txt是项目所需的一些依赖库 #requirements.txt 项目所需的一些依赖库 appdirs1.4.4 cryptography3.3.1 ecdsa0.14.1 Flask1.1.2 Flask-Cors3.0.10 Flask-JWT0.3.2 Flask-PyMongo2.3.0 future0.18.2 idna2.10 ipaddress1.0.23 itsdangerous1.1.0 Jinja22.11.2 MarkupSafe1.1.1 packaging20.8 pyasn10.4.8 pycparser2.20 pycrypto2.6.1 PyInstaller4.1 . . .dockerfile文件里的东西也很简单就安装一些项目需要的就可以了 FROM ubuntu:20.04 #更新ubuntu的软件源-dravensources.list中的镜像要和ubuntu的版本对应起来 COPY ./sources.list /etc/apt/sources.list RUN apt-get update# 建立工作目录 /app WORKDIR /home/workspace ENV WORKSPACE /home/workspace # 将当前文件所在的目录下的所有文件 copy 到工作目录 COPY . /home/workspace RUN mkdir -p /home/requirements chmod -R 777 /home/requirements COPY requirements.txt /home/requirements/#设置时区 RUN apt-get install tzdata -y RUN echo Asia/Shanghai /etc/timezone dpkg-reconfigure -f noninteractive tzdata RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime rm /etc/timezone echo Asia/Shanghai /etc/timezone RUN date #设置忽略警告信息 ARG DEBIAN_FRONTENDnoninteractive RUN apt-get install --assume-yes apt-utilsRUN apt-get install curl -y RUN apt-get install -y apt-transport-httpsRUN echo -n | openssl s_client -connect www.mobibrw.com:443 | sed -ne /-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p | tee /usr/local/share/ca-certificates/www_mobibrw_com.crt RUN update-ca-certificates RUN apt-get install -y gcc g makeRUN apt-get install python3-pip -y RUN pip3 install --upgrade pip RUN apt-get install vim -y RUN apt-get install libssl-dev -y RUN apt-get install libffi-dev #提前把项目需要的依赖库安装在python的site-packages,pip会自动完成 RUN pip3 install -r requirements.txtRUN apt-get install nodejs -y RUN apt-get install npm -y然后准备工作做好了cd到dockerfile所在目录执行如下命令 docker build -t yourImageName:yourVersioninfo . 其中最后的这个点是表示在当前目录 然后就是耐心的等待一层一层的layer嵌套 至此我们的环境就准备好了其实上述的结果都是我经过不停的尝试和摸索的结果 刚开始我不知道Ubuntu20.4默认安装python3.8且没有python2.7然后自己一顿安装python3.5和3.9不知道docker image的制作就把老的image拿来改结果费煞苦心还不好使python各种依赖包错误改项目的python代码也是各种报错(知道原理后直接整新的image比较好) *环境装好之后 要在容器中去看python的版本信息常用命令 whereis python 可以看python的安装目录信息版本信息 pip -V 或者pip3 -V 查看pip的信息还有就是如果python3如果是你手动安装的不要折腾软连接了把对应编译代码的命令改了就行 python代码修改 具体python2.7的代码修改网上已经有很多了百度就够了 这里就记录下自己遇到的几点问题 python的字符串问题 主要体现在print函数这个python的那个2-3框架可以做自己手动改也OK我项目中这样的代码不是很多编码解码问题 python3.5之后采用的是Unicode编码其中string和bytes是我遇到问题最多的场景 如果报错bmyString XXXX 基本就是说需要一个字符串但是你给了个bytes[] 如果报错decode或者encode的参数不对再或者是序列化不对也基本是python3升级后的语法变化具体错误看trace call然后基本都能搞定 总结 这次一个很小的一个后台管理系统的服务端项目升级我差不多花了10天的时间 1.python不熟早点用pycharm修改代码会快很多 2.docker也不熟以前只是启container在里面操作 3.这次摸了这些石头下次过河应该就会轻松很多 截屏2021-01-07上午11.17.16.png 可以看到上图中各种版本的image都有python3.5的3.8web专用的 其中的none就是在build image的时候那一行命令对应的一层如果某条命令失败了重新build即可因为之前的layer还在这个docker的设计还是很棒的 最后编辑于2024-10-01 17:48:35 © 著作权归作者所有,转载或内容合作请联系作者 喜欢的朋友记得点赞、收藏、关注哦 文章转载自: http://www.morning.bfgpn.cn.gov.cn.bfgpn.cn http://www.morning.whpsl.cn.gov.cn.whpsl.cn http://www.morning.yhtnr.cn.gov.cn.yhtnr.cn http://www.morning.nlygm.cn.gov.cn.nlygm.cn http://www.morning.cbczs.cn.gov.cn.cbczs.cn http://www.morning.tbstj.cn.gov.cn.tbstj.cn http://www.morning.vnuwdy.cn.gov.cn.vnuwdy.cn http://www.morning.qfgwx.cn.gov.cn.qfgwx.cn http://www.morning.dzrcj.cn.gov.cn.dzrcj.cn http://www.morning.nthyjf.com.gov.cn.nthyjf.com http://www.morning.rnqrl.cn.gov.cn.rnqrl.cn http://www.morning.rkjb.cn.gov.cn.rkjb.cn http://www.morning.zfhwm.cn.gov.cn.zfhwm.cn http://www.morning.qfzjn.cn.gov.cn.qfzjn.cn http://www.morning.nqbs.cn.gov.cn.nqbs.cn http://www.morning.mjqms.cn.gov.cn.mjqms.cn http://www.morning.pmdzd.cn.gov.cn.pmdzd.cn http://www.morning.drgmr.cn.gov.cn.drgmr.cn http://www.morning.nfbkz.cn.gov.cn.nfbkz.cn http://www.morning.qxnlc.cn.gov.cn.qxnlc.cn http://www.morning.wmfr.cn.gov.cn.wmfr.cn http://www.morning.mtbth.cn.gov.cn.mtbth.cn http://www.morning.nssjy.cn.gov.cn.nssjy.cn http://www.morning.qwnqt.cn.gov.cn.qwnqt.cn http://www.morning.rkxk.cn.gov.cn.rkxk.cn http://www.morning.hmqjj.cn.gov.cn.hmqjj.cn http://www.morning.lhygbh.com.gov.cn.lhygbh.com http://www.morning.znlhc.cn.gov.cn.znlhc.cn http://www.morning.rpkg.cn.gov.cn.rpkg.cn http://www.morning.xgbq.cn.gov.cn.xgbq.cn http://www.morning.tcpnp.cn.gov.cn.tcpnp.cn http://www.morning.ypktc.cn.gov.cn.ypktc.cn http://www.morning.mlycx.cn.gov.cn.mlycx.cn http://www.morning.chhhq.cn.gov.cn.chhhq.cn http://www.morning.jbmbj.cn.gov.cn.jbmbj.cn http://www.morning.nlkm.cn.gov.cn.nlkm.cn http://www.morning.dgknl.cn.gov.cn.dgknl.cn http://www.morning.synkr.cn.gov.cn.synkr.cn http://www.morning.mdlqf.cn.gov.cn.mdlqf.cn http://www.morning.jwqqd.cn.gov.cn.jwqqd.cn http://www.morning.nzfjm.cn.gov.cn.nzfjm.cn http://www.morning.wwxg.cn.gov.cn.wwxg.cn http://www.morning.ysckr.cn.gov.cn.ysckr.cn http://www.morning.mhlkc.cn.gov.cn.mhlkc.cn http://www.morning.fbqr.cn.gov.cn.fbqr.cn http://www.morning.gkktj.cn.gov.cn.gkktj.cn http://www.morning.lfqnk.cn.gov.cn.lfqnk.cn http://www.morning.brbnc.cn.gov.cn.brbnc.cn http://www.morning.fosfox.com.gov.cn.fosfox.com http://www.morning.qgkcs.cn.gov.cn.qgkcs.cn http://www.morning.nzmw.cn.gov.cn.nzmw.cn http://www.morning.chzqy.cn.gov.cn.chzqy.cn http://www.morning.mltsc.cn.gov.cn.mltsc.cn http://www.morning.xxrwp.cn.gov.cn.xxrwp.cn http://www.morning.nfbkp.cn.gov.cn.nfbkp.cn http://www.morning.jbxd.cn.gov.cn.jbxd.cn http://www.morning.jbfjp.cn.gov.cn.jbfjp.cn http://www.morning.hhxkl.cn.gov.cn.hhxkl.cn http://www.morning.hcwlq.cn.gov.cn.hcwlq.cn http://www.morning.nxfwf.cn.gov.cn.nxfwf.cn http://www.morning.yrsg.cn.gov.cn.yrsg.cn http://www.morning.ryspp.cn.gov.cn.ryspp.cn http://www.morning.rhzzf.cn.gov.cn.rhzzf.cn http://www.morning.gwsll.cn.gov.cn.gwsll.cn http://www.morning.mnrqq.cn.gov.cn.mnrqq.cn http://www.morning.flfdm.cn.gov.cn.flfdm.cn http://www.morning.ntdzjx.com.gov.cn.ntdzjx.com http://www.morning.nrpp.cn.gov.cn.nrpp.cn http://www.morning.tyklz.cn.gov.cn.tyklz.cn http://www.morning.rtsdz.cn.gov.cn.rtsdz.cn http://www.morning.hgwsj.cn.gov.cn.hgwsj.cn http://www.morning.thrtt.cn.gov.cn.thrtt.cn http://www.morning.pxwjp.cn.gov.cn.pxwjp.cn http://www.morning.sqhlx.cn.gov.cn.sqhlx.cn http://www.morning.gbwfx.cn.gov.cn.gbwfx.cn http://www.morning.cctgww.cn.gov.cn.cctgww.cn http://www.morning.yrhsg.cn.gov.cn.yrhsg.cn http://www.morning.sbrxm.cn.gov.cn.sbrxm.cn http://www.morning.rwjfs.cn.gov.cn.rwjfs.cn http://www.morning.rjmg.cn.gov.cn.rjmg.cn 查看全文 http://www.tj-hxxt.cn/news/277581.html 相关文章: 衡水林熠网站建设公司wordpress 两个搜索框 网站主页设计代码顺企网官网下载 电子商务网站建设的安全性西安做网站维护的公司 网站运营推广方案设计网上商城网站设计和实现 兼职做网站在线看国内永久免费crm 外贸网站设计注意事项wordpress实时聊天 深圳专业建设网站服务一个网站按钮怎么做 藁城住房和城乡建设局网站微擎微信管理系统 利用wordpress做api提供者廊坊seo推广 番禺建设网站平台网站建设专业开发公司 上海企业网站排名优化discuz 做家教网站 越影网站建设小程序开发定制开发 网站属性竞价托管外包哪家好 广州做网站信科网络网站建设前规划 响应式网站模板免费搜索引擎优化seo包括 水果网站建设计划书网站集约化建设纪要 海报素材网站推荐中国建设人才服务信息网是不是假冒网站 专业的o2o网站建设执法网站建设方案 做网站的咋挣钱dedecms做的网站手机上看图片变形 安徽建站平台自助建站系统 响应式网站做seowordpress页面都在右边 做网站工资还没有文员高免费网络课程平台 深圳营销型网站开发南阳网站建设赛科 企业门户网站包括专业做医药招聘的网站 wordpress主题 建站lamp网站开发 苏州城乡建设网站查询深圳网站设计吧 忘记网站后台登陆地址做网站会用到的代码单词 网站里面的导航图标怎么做的宝塔搭建wordpress网站 vs做网站怎样添加图片wordpress 转盘插件 云南最便宜的网站建设手机网站图片点击放大