我一直试图让django在一个docker容器中通过uwsgi运行.
我有django在docker中运行,内置了web服务器,但是现在我已经修改了requirements.txt以包含uwsgi,我不断收到以下错误消息:
连接被'NewConnectionError(':无法建立新连接:[Errno -2]名称或服务未知'重试后,重试(重试(总数= 4,连接=无,读取=无,重定向=无)) ':/ simple/uwsgi /
所以看起来url docker用于pip包/simple
,但是这是怎么改变的?当我第一次创建容器时,django和psycopg下载得很好.
我尝试指定uwsgi包的完整URL,但这也不起作用.
泊坞窗,compose.yaml:
version: '3'
services:
db:
image: postgres
web:
dns: 8.8.8.8
build: .
command: uwsgi --http :8000 --module destExp.wsgi
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
Run Code Online (Sandbox Code Playgroud)
Dockerfile:
FROM python:3.5
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/
CMD uwsgi --http :8000 --module destExp.wsgi
Run Code Online (Sandbox Code Playgroud) 这尤其在 RHEL 上发生 已经安装了这个包 yum install libxml2-devel xmlsec1-devel xmlsec1-openssl-devel libtool-ltdl-devel
Could not find xmlsec1 config. Are libxmlsec1-dev and pkg-config installed
Command "/usr/local/pyenv/versions/3.6.5/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ucm4xpg5/xmlsec/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-gr0ttbdf/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-ucm4xpg5/xmlsec/
Run Code Online (Sandbox Code Playgroud)
为什么我收到此错误即使我安装了所需的软件包
我正在使用 Visual Studio Code 并且 PEP8 会自动格式化我的代码的一部分,我只是在学习 lambdas 并且我有一个像这样的 3 行代码:
它来自这3 行代码:
# Lambda example
divide = lambda x, y: x/y
print(divide(10, 2))
Run Code Online (Sandbox Code Playgroud)
对于这7 行代码:
# Lambda example
def divide(x, y): return x/y
print(divide(10, 2))
Run Code Online (Sandbox Code Playgroud)
有谁知道我如何让这个程序特别不将我的 lambda 函数转换为 def 函数?
它已经很好地格式化了我的代码,所以我不想完全禁用这个自动功能,只是为了 lambda 的事情。
我刚刚为我的 Django 存储库设置了Black和Pre-Commit。
我在我遵循的教程中使用了 Black 的默认配置,它运行良好,但我无法从中排除我的迁移文件。
这是我一直在使用的默认配置:
pyproject.toml
[tool.black]
line-length = 79
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''
Run Code Online (Sandbox Code Playgroud)
我使用Regex101.com来确保^.*\b(migrations)\b.*$
匹配apps/examples/migrations/test.py
.
[tool.black]
line-length = 79
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| ^.*\b(migrations)\b.*$
)/ …
Run Code Online (Sandbox Code Playgroud) 在 VSCode 中使用以下命令成功安装预提交:
python3 -m pip install pre-commit --user
Run Code Online (Sandbox Code Playgroud)
但是当我尝试进行预提交安装时,我收到错误消息:
zsh: command not found: pre-commit
Run Code Online (Sandbox Code Playgroud) 将https://pre-commit.com与依赖于 Python venv 中安装的包的 VSCode 挂钩使用时。在预提交上可以指定使用“系统”作为环境。这在具有所需 venv 活动的终端上非常有效。
然而,使用集成的源代码控制似乎可以访问全局 interpeter,因此所需的包不可用。
这里有解决方法吗?至于现在我在预提交配置中指定入口点“path/to/bin/python -m package”。但是我确实认为集成的源代码控制也应该至少尊重选定的互操作者。
有什么想法吗?
在$ company公司,我们运行一个内部pypi服务器,以保护自己免受公共pypi停机.我们还构建了轮子以避免二进制包的安装开销.一个常见的任务是从公共pypi导入包,其基本归结为:
pip install --download . --no-binary :all: $PACKAGE # download a source distribution
Run Code Online (Sandbox Code Playgroud)
和
pip wheel $PACKAGE # build a binary distribution (or use a cached version that's already on our internal pypi)
Run Code Online (Sandbox Code Playgroud)
根据最新的点,这可能会manylinux
在pip wheel
阶段下载/安装车轮.由于捆绑.so文件在车轮内,这些与$ company的安全要求不兼容.我们如何在避开manylinux车轮的同时继续保持相同的工作流程?
目前我们正在降级pip<8
,但这似乎并不理想
当尝试使用 Poetry 安装 Python 依赖项时,出现以下错误:
$ poetry install
The currently activated Python version 2.7.15 is not supported by the project (>=3.6).
Trying to find and use a compatible version.
Using python3 (3.7.4)
Skipping virtualenv creation, as specified in config file.
Updating dependencies
Resolving dependencies... (1.7s)
[SolverProblemError]
The current project's Python requirement (>=3.6) is not compatible with some of the required packages Python requirement:
- pre-commit requires Python >=3.6.1
Because no versions of pre-commit match >2.2.0,<3.0.0
and pre-commit (2.2.0) requires Python …
Run Code Online (Sandbox Code Playgroud) 我正在Mypy v0.910
跑步pre-commit
。它抱怨python-dateutil
没有类型存根。但是,即使安装了存根后,我仍然遇到相同的错误。
我的预提交配置是
default_language_version:
python: python3
repos:
<other hooks>
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
hooks:
- id: mypy
args:
- --install-types
additional_dependencies: [tokenize-rt==3.2.0]
Run Code Online (Sandbox Code Playgroud)
当我尝试提交时,它抱怨存根不存在,然后无法安装它们。
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1
coordinator/policy.py:5: error: Library stubs not installed for "dateutil.parser" (or incompatible with Python 3.7)
coordinator/policy.py:5: note: Hint: "python3 -m pip install types-python-dateutil"
coordinator/policy.py:5: note: (or run "mypy --install-types" to install all missing stub packages)
tests/test_policy.py:6: error: Cannot find implementation or library stub …
Run Code Online (Sandbox Code Playgroud) 我已经使用这个pre-commit
工具很多年了!它一直工作得很好,直到最近它开始失败并出现一条神秘的错误消息:
$ pre-commit run flake8 --all-files
An error has occurred: InvalidConfigError:
==> File .pre-commit-config.yaml
=====> Expected a Config map but got a list
Check the log at /home/asottile/.cache/pre-commit/pre-commit.log
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
python ×6
python-3.x ×3
pip ×2
pre-commit ×2
autopep8 ×1
django ×1
docker ×1
mypy ×1
pep8 ×1
python-wheel ×1
regex ×1
rhel7 ×1
xmlsec1 ×1