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
相关文章
|
1月前
|
机器学习/深度学习 人工智能 开发工具
人工智能项目的python版本管理工具DVC
dvc即data version control, 是一种针对人工智能项目(机器学习或者深度学习)的数据版本管理工具。DVC的操作和GIT类似,可以认为为GIT的二次开发封装。结合GIT,DVC可以有效的管理人工智能项目的整个流程,包括代码,数据,训练配置,模型【2月更文挑战第12天】
51 1
|
2月前
|
缓存 前端开发 测试技术
(译)Python 官方团队在打包项目中踩过的坑
(译)Python 官方团队在打包项目中踩过的坑
31 2
|
2月前
|
数据采集 存储 架构师
上进计划 | Python爬虫经典实战项目——电商数据爬取!
在如今这个网购风云从不间歇的时代,购物狂欢持续不断,一年一度的“6.18年中大促”、“11.11购物节”等等成为了网购电商平台的盛宴。在买买买的同时,“如何省钱?”成为了大家最关心的问题。 比价、返利、优惠券都是消费者在网购时的刚需,但在这些“优惠”背后已产生灰色地带。
|
3月前
|
机器学习/深度学习 存储 网络架构
Python 智能项目:6~10(5)
Python 智能项目:6~10(5)
|
3月前
|
存储 Python
Python实战项目(十三)使用 Tkinter GUI 库构建闹钟应用程序
Python实战项目(十三)使用 Tkinter GUI 库构建闹钟应用程序
37 0
|
20天前
|
前端开发 JavaScript 数据管理
描述一个使用Python开发Web应用程序的实际项目经验,包括所使用的框架和技术栈。
使用Flask开发Web应用,结合SQLite、Flask-SQLAlchemy进行数据管理,HTML/CSS/JS(Bootstrap和jQuery)构建前端。通过Flask路由处理用户请求,模块化代码提高可维护性。unittest进行测试,开发阶段用内置服务器,生产环境可选WSGI服务器或容器化部署。实现了用户注册登录和数据管理功能,展示Python Web开发的灵活性和效率。
14 4
|
1月前
|
Linux 数据库连接 数据库
Python如何将项目直接打包为一键整合包
Python如何将项目直接打包为一键整合包
39 0
|
1月前
|
数据采集 存储 数据处理
Python爬虫在Django项目中的数据处理与展示实例
Python爬虫在Django项目中的数据处理与展示实例
|
1月前
|
人工智能 开发工具 git
第一次运行 Python 项目,使用 python-pptx 提取 ppt 中的文字和图片
人工智能时代,最需要学习的编程语言是:python 。笔者是个 python 小白,昨天花了两个小时,第一次成功运行起来 python 项目 。 项目是 powerpoint-extractor ,可以将 ppt 文件中的图片提取出来,并输出到固定的目录。
第一次运行 Python 项目,使用 python-pptx 提取 ppt 中的文字和图片
|
2月前
|
Web App开发 人工智能 Kubernetes
Python 潮流周刊#23:35 个容易上手的 Python 小项目
Python 潮流周刊#23:35 个容易上手的 Python 小项目
20 1