python3.5项目升级3.8问题汇总

简介: 服务器:Ubuntu 16.04.4 LTS当前Python版本:3.5.2待升级Python版本:3.8.x项目框架:Django2.0.9

服务器:Ubuntu 16.04.4 LTS
当前Python版本:3.5.2
待升级Python版本:3.8.x
项目框架:Django2.0.9

问题1:uwsgi

  • 虚拟环境创建完成,但是在pip安装的时候遇到了第一个问题,uwsgi安装报错。

        Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
    Collecting uWSGI
      Using cached http://mirrors.aliyun.com/pypi/packages/24/fd/93851e4a076719199868d4c918cc93a52742e68370188c1c570a6e42a54f/uwsgi-2.0.20.tar.gz (804 kB)
      Preparing metadata (setup.py) ... done
    Building wheels for collected packages: uWSGI
      Building wheel for uWSGI (setup.py) ... error
      ERROR: Command errored out with exit status 1:
       command: /var/www/xxxx_service/venv/bin/python3.8 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zsha325q/uwsgi_51aeb00d5183497a974b06a81f9c2458/setup.py'"'"'; __file__='"'"'/tmp/pip-install-zsha325q/uwsgi_51aeb00d5183497a974b06a81f9c2458/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-ptbf967q
           cwd: /tmp/pip-install-zsha325q/uwsgi_51aeb00d5183497a974b06a81f9c2458/
      Complete output (181 lines):
      /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'descriptions'
      ......
      ......
      ......
        collect2: error: ld returned 1 exit status
        *** error linking uWSGI ***
        ----------------------------------------
    ERROR: Command errored out with exit status 1: /var/www/xxxx_service/venv/bin/python3.8 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zsha325q/uwsgi_51aeb00d5183497a974b06a81f9c2458/setup.py'"'"'; __file__='"'"'/tmp/pip-install-zsha325q/uwsgi_51aeb00d5183497a974b06a81f9c2458/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-e0wfuy2_/install-record.txt --single-version-externally-managed --compile --install-headers /var/www/xxxx_service/venv/include/site/python3.8/uWSGI Check the logs for full command output.

问题1解决方案

  • 方案一,Ubuntu安装uWSGI失败处理,失败

    apt-get install libpython3.8-dev
  • 方案二,失败

    apt-get install build-essential libssl-dev libffi-dev python-dev
  • 方案三,成功,放弃uwsgi,改用pyuwsgi。虽然这个成功了 但是个人不建议使用,毕竟改变了项目原来的库,哪位大佬有更好的解决方案麻烦分享一下,不胜感谢。

    pip install pyuwsgi

问题2:celery

  • celery报错

    /mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/platforms.py:797: RuntimeWarning: You're running the worker with superuser privileges: this is
    absolutely not recommended!
    
    Please specify a different user using the --uid option.
    
    User information: uid=0 euid=0 gid=0 egid=0
    
      warnings.warn(RuntimeWarning(ROOT_DISCOURAGED.format(
    Traceback (most recent call last):
      File "/var/www/xxxx_service/venv/bin/celery", line 8, in <module>
        sys.exit(main())
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/__main__.py", line 15, in main
        sys.exit(_main())
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/bin/celery.py", line 150, in main
        return celery(auto_envvar_prefix="CELERY")
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
        return self.main(*args, **kwargs)
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/click/core.py", line 1053, in main
        rv = self.invoke(ctx)
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/click/core.py", line 754, in invoke
        return __callback(*args, **kwargs)
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
        return f(get_current_context(), *args, **kwargs)
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/bin/worker.py", line 323, in worker
        worker = app.Worker(
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/worker/worker.py", line 99, in __init__
        self.setup_instance(**self.prepare_args(**kwargs))
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/worker/worker.py", line 139, in setup_instance
        self.blueprint.apply(self, **kwargs)
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/bootsteps.py", line 211, in apply
        step.include(parent)
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/bootsteps.py", line 339, in include
        return self._should_include(parent)[0]
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/bootsteps.py", line 335, in _should_include
        return True, self.create(parent)
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/worker/components.py", line 211, in create
        w._persistence = w.state.Persistent(w.state, w.statedb, w.app.clock)
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/worker/state.py", line 189, in __init__
        self.merge()
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/worker/state.py", line 197, in merge
        self._merge_with(self.db)
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/kombu/utils/objects.py", line 29, in __get__
        return super().__get__(instance, owner)
      File "/usr/lib/python3.8/functools.py", line 967, in __get__
        val = self.func(instance)
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/worker/state.py", line 266, in db
        return self.open()
      File "/mnt/var/www/xxxx_service/venv/lib/python3.8/site-packages/celery/worker/state.py", line 192, in open
        return self.storage.open(
      File "/usr/lib/python3.8/shelve.py", line 243, in open
        return DbfilenameShelf(filename, flag, protocol, writeback)
      File "/usr/lib/python3.8/shelve.py", line 227, in __init__
        Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
      File "/usr/lib/python3.8/dbm/__init__.py", line 91, in open
        raise error[0]("db type is {0}, but the module is not "
    dbm.error: db type is dbm.gnu, but the module is not available

问题2解决方案

apt-get install python3.8-gdbm

问题3:Crypto

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/www/xxxx_service/venv3.8/lib/python3.8/site-packages/Crypto/Signature/PKCS1_v1_5.py", line 112, in sign
  File "/var/www/xxxx_service/venv3.8/lib/python3.8/site-packages/Crypto/PublicKey/RSA.py", line 174, in decrypt
    return result
  File "/var/www/xxxx_service/venv3.8/lib/python3.8/site-packages/Crypto/PublicKey/pubkey.py", line 93, in decrypt
    plaintext=self._decrypt(ciphertext)
  File "/var/www/xxxx_service/venv3.8/lib/python3.8/site-packages/Crypto/PublicKey/RSA.py", line 235, in _decrypt
    - *'PEM'*. (*Default*) Text encoding, done according to `RFC1421`_/`RFC1423`_.
  File "/var/www/xxxx_service/venv3.8/lib/python3.8/site-packages/Crypto/Util/number.py", line 123, in getRandomRange
    return y
  File "/var/www/xxxx_service/venv3.8/lib/python3.8/site-packages/Crypto/Util/number.py", line 104, in getRandomInteger
    If :data:`randfunc` is omitted, then :meth:`Random.get_random_bytes` is used.
  File "/var/www/xxxx_service/venv3.8/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 202, in read
    return self._singleton.read(bytes)
  File "/var/www/xxxx_service/venv3.8/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 178, in read
    return _UserFriendlyRNG.read(self, bytes)
  File "/var/www/xxxx_service/venv3.8/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 129, in read
    self._ec.collect()
  File "/var/www/xxxx_service/venv3.8/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 77, in collect
    t = time.clock()
AttributeError: module 'time' has no attribute 'clock'

问题3解决方案

  • crypto已经停更了,需要安装pycryptodome

    pip install pycryptodome
相关文章
|
2月前
|
机器学习/深度学习 数据采集 数据可视化
Python 数据分析:从零开始构建你的数据科学项目
【10月更文挑战第9天】Python 数据分析:从零开始构建你的数据科学项目
65 2
|
3月前
|
机器学习/深度学习 算法 TensorFlow
动物识别系统Python+卷积神经网络算法+TensorFlow+人工智能+图像识别+计算机毕业设计项目
动物识别系统。本项目以Python作为主要编程语言,并基于TensorFlow搭建ResNet50卷积神经网络算法模型,通过收集4种常见的动物图像数据集(猫、狗、鸡、马)然后进行模型训练,得到一个识别精度较高的模型文件,然后保存为本地格式的H5格式文件。再基于Django开发Web网页端操作界面,实现用户上传一张动物图片,识别其名称。
111 1
动物识别系统Python+卷积神经网络算法+TensorFlow+人工智能+图像识别+计算机毕业设计项目
|
24天前
|
存储 数据可视化 数据挖掘
Python数据分析项目:抖音短视频达人粉丝增长趋势
Python数据分析项目:抖音短视频达人粉丝增长趋势
|
28天前
|
监控 安全 测试技术
如何在实际项目中应用Python Web开发的安全测试知识?
如何在实际项目中应用Python Web开发的安全测试知识?
28 4
|
1月前
|
弹性计算 Linux iOS开发
Python 虚拟环境全解:轻松管理项目依赖
本文详细介绍了 Python 虚拟环境的概念、创建和使用方法,包括 `virtualenv` 和 `venv` 的使用,以及最佳实践和注意事项。通过虚拟环境,你可以轻松管理不同项目的依赖关系,避免版本冲突,提升开发效率。
90 3
|
3月前
|
机器学习/深度学习 人工智能 算法
植物病害识别系统Python+卷积神经网络算法+图像识别+人工智能项目+深度学习项目+计算机课设项目+Django网页界面
植物病害识别系统。本系统使用Python作为主要编程语言,通过收集水稻常见的四种叶片病害图片('细菌性叶枯病', '稻瘟病', '褐斑病', '稻瘟条纹病毒病')作为后面模型训练用到的数据集。然后使用TensorFlow搭建卷积神经网络算法模型,并进行多轮迭代训练,最后得到一个识别精度较高的算法模型,然后将其保存为h5格式的本地模型文件。再使用Django搭建Web网页平台操作界面,实现用户上传一张测试图片识别其名称。
142 22
植物病害识别系统Python+卷积神经网络算法+图像识别+人工智能项目+深度学习项目+计算机课设项目+Django网页界面
|
2月前
|
JSON 搜索推荐 API
Python的web框架有哪些?小项目比较推荐哪个?
【10月更文挑战第15天】Python的web框架有哪些?小项目比较推荐哪个?
75 1
|
2月前
|
机器学习/深度学习 人工智能 算法
【玉米病害识别】Python+卷积神经网络算法+人工智能+深度学习+计算机课设项目+TensorFlow+模型训练
玉米病害识别系统,本系统使用Python作为主要开发语言,通过收集了8种常见的玉米叶部病害图片数据集('矮花叶病', '健康', '灰斑病一般', '灰斑病严重', '锈病一般', '锈病严重', '叶斑病一般', '叶斑病严重'),然后基于TensorFlow搭建卷积神经网络算法模型,通过对数据集进行多轮迭代训练,最后得到一个识别精度较高的模型文件。再使用Django搭建Web网页操作平台,实现用户上传一张玉米病害图片识别其名称。
72 0
【玉米病害识别】Python+卷积神经网络算法+人工智能+深度学习+计算机课设项目+TensorFlow+模型训练
|
3月前
|
机器学习/深度学习 算法 TensorFlow
交通标志识别系统Python+卷积神经网络算法+深度学习人工智能+TensorFlow模型训练+计算机课设项目+Django网页界面
交通标志识别系统。本系统使用Python作为主要编程语言,在交通标志图像识别功能实现中,基于TensorFlow搭建卷积神经网络算法模型,通过对收集到的58种常见的交通标志图像作为数据集,进行迭代训练最后得到一个识别精度较高的模型文件,然后保存为本地的h5格式文件。再使用Django开发Web网页端操作界面,实现用户上传一张交通标志图片,识别其名称。
123 6
交通标志识别系统Python+卷积神经网络算法+深度学习人工智能+TensorFlow模型训练+计算机课设项目+Django网页界面
|
3月前
|
机器学习/深度学习 人工智能 算法
【新闻文本分类识别系统】Python+卷积神经网络算法+人工智能+深度学习+计算机毕设项目+Django网页界面平台
文本分类识别系统。本系统使用Python作为主要开发语言,首先收集了10种中文文本数据集("体育类", "财经类", "房产类", "家居类", "教育类", "科技类", "时尚类", "时政类", "游戏类", "娱乐类"),然后基于TensorFlow搭建CNN卷积神经网络算法模型。通过对数据集进行多轮迭代训练,最后得到一个识别精度较高的模型,并保存为本地的h5格式。然后使用Django开发Web网页端操作界面,实现用户上传一段文本识别其所属的类别。
107 1
【新闻文本分类识别系统】Python+卷积神经网络算法+人工智能+深度学习+计算机毕设项目+Django网页界面平台
下一篇
DataWorks