Readthedocs.org: 尽管在 virtualenv 中使用 python 3.6 开始,但用于 doc 构建的 Python 解释器被强制使用 Python 3.7

创建于 2019-02-21  ·  4评论  ·  资料来源: readthedocs/readthedocs.org

细节

这发生在尝试触发文档构建时,即使对于演示项目也是如此。 在 Ubuntu 18.04 和 Amazon Linux 2 上进行全新安装。

我的 Ubuntu 脚本:

apt update
apt upgrade -y
apt install -y latexmk texlive texlive-science texlive-formats-extra git redis python3-dev

git clone https://github.com/rtfd/readthedocs.org.git
cd readthedocs.org
echo "    SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')" >> readthedocs/settings/base.py

python3 -m venv --without-pip venv
source venv/bin/activate
curl -s https://bootstrap.pypa.io/get-pip.py | python

pip install -r requirements.txt
pip install django-allauth

python manage.py migrate
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin<strong i="8">@localhost</strong>', 'admin')" | python ./manage.py shell
python manage.py collectstatic
python manage.py loaddata test_data

python manage.py runserver 0.0.0.0:8000

错误:

[21/Feb/2019 19:22:26] readthedocs.doc_builder.environments:599[1832]: WARNING (Build) [admin-demo:latest] Command python3.7 -mvirtualenv --no-site-packages --no-download /home/ubuntu/readthedocs.org/user_builds/admin-demo/envs/latest failed:
Traceback (most recent call last):
  File "/home/ubuntu/readthedocs.org/readthedocs/doc_builder/environments.py", line 178, in run
    env=environment,
  File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'python3.7': 'python3.7'
Traceback (most recent call last):
  File "/home/ubuntu/readthedocs.org/readthedocs/projects/tasks.py", line 558, in run_build
    self.setup_python_environment()
  File "/home/ubuntu/readthedocs.org/readthedocs/projects/tasks.py", line 784, in setup_python_environment
    self.python_env.setup_base()
  File "/home/ubuntu/readthedocs.org/readthedocs/doc_builder/python_environments.py", line 258, in setup_base
    cwd='$HOME',
  File "/home/ubuntu/readthedocs.org/readthedocs/doc_builder/environments.py", line 612, in run
    return super().run(*cmd, **kwargs)
  File "/home/ubuntu/readthedocs.org/readthedocs/doc_builder/environments.py", line 403, in run
    return self.run_command_class(cls=self.command_class, cmd=cmd, **kwargs)
  File "/home/ubuntu/readthedocs.org/readthedocs/doc_builder/environments.py", line 618, in run_command_class
    return super().run_command_class(*cmd, **kwargs)
  File "/home/ubuntu/readthedocs.org/readthedocs/doc_builder/environments.py", line 472, in run_command_class
    raise BuildEnvironmentWarning(msg)
readthedocs.doc_builder.exceptions.BuildEnvironmentWarning: Command python3.7 -mvirtualenv --no-site-packages --no-download /home/ubuntu/readthedocs.org/user_builds/admin-demo/envs/latest failed:
Traceback (most recent call last):
  File "/home/ubuntu/readthedocs.org/readthedocs/doc_builder/environments.py", line 178, in run
    env=environment,
  File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'python3.7': 'python3.7'

预期结果

文档构建

实际结果

缺少 Python 3.7 时出错

几天前,当我尝试使用相同的设置脚本时,这并没有发生。

最有用的评论

考虑到您不支持 Python 3.7 来运行应用程序(#4756),这似乎是一种奇怪的状态。

为什么默认需要两个版本的 Python? 对于默认行为,这不是一个好的状态。

所有4条评论

文档构建与应用程序是分开的。 我们在最新版本中默认为 3.7。 您可以使用配置文件来使用另一个 python 版本或从 readthedocs/settings 更改默认设置

请解释如何做到这一点。 这有记录吗?

使用配置文件https://docs.readthedocs.io/en/stable/config-file/v2.html

或者您可以从设置中删除 3.7 https://github.com/rtfd/readthedocs.org/blob/ed8dd29a68d009fc08929fabf7155883482619c1/readthedocs/settings/base.py#L292 -L294(因为我们从最新图像中获取最新版本)

我们在生产中使用 docker

考虑到您不支持 Python 3.7 来运行应用程序(#4756),这似乎是一种奇怪的状态。

为什么默认需要两个版本的 Python? 对于默认行为,这不是一个好的状态。

此页面是否有帮助?
0 / 5 - 0 等级