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.
    AI 代码解读

问题1解决方案

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

    apt-get install libpython3.8-dev
    AI 代码解读
  • 方案二,失败

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

    pip install pyuwsgi
    AI 代码解读

问题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
    AI 代码解读

问题2解决方案

apt-get install python3.8-gdbm
AI 代码解读

问题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'
AI 代码解读

问题3解决方案

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

    pip install pycryptodome
    AI 代码解读
目录
打赏
0
0
0
0
4
分享
相关文章
Python 技术员实践指南:从项目落地到技术优化
本内容涵盖Python开发的实战项目、技术攻关与工程化实践,包括自动化脚本(日志分析系统)和Web后端(轻量化API服务)两大项目类型。通过使用正则表达式、Flask框架等技术,解决日志分析效率低与API服务性能优化等问题。同时深入探讨内存泄漏排查、CPU瓶颈优化,并提供团队协作规范与代码审查流程。延伸至AI、大数据及DevOps领域,如商品推荐系统、PySpark数据处理和Airflow任务编排,助力开发者全面提升从编码到架构的能力,积累高并发与大数据场景下的实战经验。
Python 技术员实践指南:从项目落地到技术优化
|
20天前
|
魔搭notebook在web IDE下,使用jupyter notebook,python扩展包无法更新升级
魔搭notebook在web IDE下,使用jupyter notebook,python扩展包无法更新升级,不升级无法使用,安装python扩展包的时候一直停留在installing
41 4
|
2月前
|
解读 Python 3.14:模板字符串、惰性类型、Zstd压缩等7大核心功能升级
Python 3.14 引入了七大核心技术特性,大幅提升开发效率与应用安全性。其中包括:t-strings(PEP 750)提供更安全灵活的字符串处理;类型注解惰性求值(PEP 649)优化启动性能;外部调试器API标准化(PEP 768)增强调试体验;原生支持Zstandard压缩算法(PEP 784)提高效率;REPL交互环境升级更友好;UUID模块扩展支持新标准并优化性能;finally块语义强化(PEP 765)确保资源清理可靠性。这些改进使Python在后端开发、数据科学等领域更具竞争力。
107 5
解读 Python 3.14:模板字符串、惰性类型、Zstd压缩等7大核心功能升级
怎么开发Python第三方库?手把手教你参与开源项目!
大家好,我是程序员晚枫。本文将分享如何开发Python第三方库,并以我维护的开源项目 **popdf** 为例,指导参与开源贡献。Popdf是一个PDF操作库,支持PDF转Word、转图片、合并与加密等功能。文章涵盖从fork项目、本地开发、单元测试到提交PR的全流程,适合想了解开源贡献的开发者。欢迎访问[popdf](https://gitcode.com/python4office/popdf),一起交流学习!
148 21
怎么开发Python第三方库?手把手教你参与开源项目!
Python 数据分析:从零开始构建你的数据科学项目
【10月更文挑战第9天】Python 数据分析:从零开始构建你的数据科学项目
174 2
【03】做一个精美的打飞机小游戏,规划游戏项目目录-分门别类所有的资源-库-类-逻辑-打包为可玩的exe-练习python打包为可执行exe-优雅草卓伊凡-持续更新-分享源代码和游戏包供游玩-1.0.2版本
【03】做一个精美的打飞机小游戏,规划游戏项目目录-分门别类所有的资源-库-类-逻辑-打包为可玩的exe-练习python打包为可执行exe-优雅草卓伊凡-持续更新-分享源代码和游戏包供游玩-1.0.2版本
249 31
【03】做一个精美的打飞机小游戏,规划游戏项目目录-分门别类所有的资源-库-类-逻辑-打包为可玩的exe-练习python打包为可执行exe-优雅草卓伊凡-持续更新-分享源代码和游戏包供游玩-1.0.2版本
Docker——阿里云服务器使用Docker部署python项目全程小记
本文记录了我在阿里云服务器上使用Docker部署python项目(flask为例)的全过程,在这里记录和分享一下,希望可以给大家提供一些参考。
409 0
宝塔面板升级python3
Python 是一种广泛使用的高级编程语言,因其简洁的语法和丰富的库而受到开发者的喜爱。在许多Web应用程序和后端开发环境中,Python已成为重要工具。使用宝塔面板时,保持Python更新至关重要。本文介绍如何在服务器上安全升级Python:从环境准备、检查当前版本、安装工具包、下载并编译新版本、配置环境变量到测试新版本,确保升级顺利进行。建议定期更新以利用新特性和性能改进,并备份数据以防万一。
193 6
|
7月前
|
课程设计项目之基于Python实现围棋游戏代码
游戏进去默认为九路玩法,当然也可以选择十三路或是十九路玩法 使用pycharam打开项目,pip安装模块并引用,然后运行即可, 代码每行都有详细的注释,可以做课程设计或者毕业设计项目参考
145 33
如何在实际项目中应用Python Web开发的安全测试知识?
如何在实际项目中应用Python Web开发的安全测试知识?
153 61

推荐镜像

更多
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等

登录插画

登录以查看您的控制台资源

管理云资源
状态一览
快捷访问