python3安装setuptools步骤_Django,python3,在安装时我得到:“父模块'setuptools'未加载”...

1586010002-jmsa.png

I see lots of errors and suggestions about Parent module '' not loaded, ...

I don't see any about specifically "out of the box" django 3.5.

$ mkvirtualenv foobar -p /usr/bin/python3

Already using interpreter /usr/bin/python3

Using base prefix '/usr'

New python executable in /home/isaac/.virtualenvs/foobar/bin/python3

Also creating executable in /home/isaac/.virtualenvs/foobar/bin/python

Installing setuptools, pkg_resources, pip, wheel...done.

[foobar] $ pip install django

Collecting django

Using cached Django-2.2.15-py3-none-any.whl (7.5 MB)

Collecting pytz

Using cached pytz-2020.1-py2.py3-none-any.whl (510 kB)

Collecting sqlparse>=0.2.2

Using cached sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)

Installing collected packages: pytz, sqlparse, django

Successfully installed django-2.2.15 pytz-2020.1 sqlparse-0.3.1

[foobar] $ python

Python 3.5.3 (default, Jul 9 2020, 13:00:10)

[GCC 6.3.0 20170516] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> import django

Traceback (most recent call last):

File "", line 1, in

File "/home/isaac/.virtualenvs/foobar/lib/python3.5/site-packages/django/__init__.py", line 1, in

from django.utils.version import get_version

File "/home/isaac/.virtualenvs/foobar/lib/python3.5/site-packages/django/utils/version.py", line 6, in

from distutils.version import LooseVersion

File "", line 969, in _find_and_load

File "", line 958, in _find_and_load_unlocked

File "", line 666, in _load_unlocked

File "", line 577, in module_from_spec

File "/home/isaac/.virtualenvs/foobar/lib/python3.5/site-packages/_distutils_hack/__init__.py", line 82, in create_module

return importlib.import_module('._distutils', 'setuptools')

File "/home/isaac/.virtualenvs/foobar/lib/python3.5/importlib/__init__.py", line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

File "", line 981, in _gcd_import

File "", line 931, in _sanity_check

SystemError: Parent module 'setuptools' not loaded, cannot perform relative import

As you can see, I installed django using python3.5.

It seems to work fine with python2.7...

Is anyone else aware of a way around this bug, or something silly I did in my environment?

I am using debian stretch instead of buster, but I'm not sure if I'm ready to upgrade yet.

解决方案

Something happened in version 50 of setuptools.

We could "solve" this problem by downgrading setuptools to 49.3.0 (and maybe pip to 20.2.1)

pip install setuptools==49.3.0 and pip install pip==20.2.1

Be aware though that this should only be a temporary solution!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值