我在 Linux Mint 17.1 中安装了 Python 3.4.2和 Virtualenv 12.0.5
然后我尝试创建:
$ virtualenv venv
并且还使用 --clear 和/或 -p /usr/bin/python3.4,总是收到消息:
Using base prefix '/usr'
New python executable in venv/bin/python3
Also creating executable in venv/bin/python
ERROR: The executable venv/bin/python3 could not be run: [Errno 13] Permission denied
另一种尝试是:
$ pyvenv-3.4 venv
它在创建时没有给出错误,但在 venv/bin 文件中,python3.4 是到 /usr/local/bin/python3.4 的符号链接。然后,当我使用 pip 或 pip3 激活并安装任何库,然后尝试导入它时,出现错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'anymoduledownloaded'
我总是在 Python 2.X 中使用 …
我在新安装的 Ubuntu 18.04.2 LTS 上创建了 1.15.0 单节点 kubeadm。然后我删除了集群并重新创建了它。但现在我无法再重新创建它(我收到 etcd 预检检查错误):
[init] Using Kubernetes version: v1.15.0
[preflight] Running pre-flight checks
[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR DirAvailable--var-lib-etcd]: /var/lib/etcd is not empty
Run Code Online (Sandbox Code Playgroud)
我使用过的命令是:
# created a single node
sudo swapoff -a
sudo kubeadm init --pod-network-cidr=192.168.0.0/16
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) …Run Code Online (Sandbox Code Playgroud) 我有一个带有 Python-click 的命令行脚本,带有参数和选项:
# console.py
import click
@click.command()
@click.version_option()
@click.argument("filepath", type=click.Path(exists=True), default=".")
@click.option(
"-m",
"--max-size",
type=int,
help="Max size in megabytes.",
default=20,
show_default=True,
)
def main(filepath: str, max_size: int) -> None:
max_size_bytes = max_size * 1024 * 1024 # convert to MB
if filepath.endswith(".pdf"):
print("success")
else:
print(max_size_bytes)
Run Code Online (Sandbox Code Playgroud)
参数和选项都有默认值,并且在命令行上工作,并且使用 CLI 时它的行为符合预期。但是当我尝试按照 Click文档测试它并调试它时,它不会进入第一行:
# test_console.py
from unittest.mock import Mock
import click.testing
import pytest
from pytest_mock import MockFixture
from pdf_split_tool import console
@pytest.fixture
def runner() -> click.testing.CliRunner:
"""Fixture for invoking command-line interfaces.""" …Run Code Online (Sandbox Code Playgroud) 我有一个带有方法的类:
class TimeUtilitiesTestCase():
def test_date_and_delta(self) -> None:
"""Tests date_and_delta utility method."""
now = datetime.datetime.now()
tdelta = datetime.timedelta
int_tests = (3, 29, 86399, 86400, 86401 * 30)
date_tests = [now - tdelta(seconds=x) for x in int_tests]
td_tests = [tdelta(seconds=x) for x in int_tests]
results = [(now - tdelta(seconds=x), tdelta(seconds=x)) for x in int_tests]
for test in (int_tests, date_tests, td_tests):
for arg, result in zip(test, results):
dtime, delta = humanizer_portugues.time.date_and_delta(arg)
self.assertEqualDatetime(dtime, result[0])
self.assertEqualTimedelta(delta, result[1])
self.assertEqual(humanizer_portugues.time.date_and_delta("NaN"), (None, "NaN"))
Run Code Online (Sandbox Code Playgroud)
我正在运行严格的 mypy 检查(此处配置),但出现错误: …
我尝试下载示例交互式问题猜数字问题。他们local testing tool在“描述”选项卡中提供了一个Python解决方案,在“分析”选项卡中提供了一个同时运行两个脚本的interactive_runner.py 。
将解决方案保存在 中后solution.py,我可以使用以下命令在 shell 上成功运行它:python3 interactive_runner.py python3 local_testing_tool.py 0 -- python3 solution.py。
问题是我无法使用 VSCode 进行调试。我尝试将所有 3 个文件放在一个文件夹中并使用以下 launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Arquivo Atual",
"type": "python",
"request": "launch",
"program": "interactive_runner.py python3 local_testing_tool.py 0 -- python3 ${file}",
"console": "integratedTerminal",
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我使用调试器运行解决方案.py 时,出现错误:
env DEBUGPY_LAUNCHER_PORT=40453 /home/user/.pyenv/versions/3.8.2/bin/python3.8 /home/user/.vscode/extensions/ms-python.python-2020.4.74986/pythonFiles/lib/python/debugpy/no_wheels/debugpy/launcher "interactive_runner.py python3 local_testing_tool.py 0 -- python3 /home/user/workspace/wargames/GoogleCodeJam/2018/PracticeSession/NumberGuessing/solution.py"
Traceback (most recent call last):
File "/home/user/.pyenv/versions/3.8.2/lib/python3.8/runpy.py", line 193, in …Run Code Online (Sandbox Code Playgroud) 我试图通过Bootstrap和CSS进入响应式设计/布局,但我有点担心如何更改框位于屏幕中心.
我有一个登录窗格,在谷歌浏览器中的大小为277x256(该大小适合许多智能手机屏幕).所以我做了一个这样的CSS:
.login .pane {
position: absolute;
top: 50%;
left: 50%;
margin: -128px -138.5px; /* half of the size in Google Chrome */
background: #f0f0fd;
background: rgba(240,240,253,0.90);
padding: 22px 32px;
}
Run Code Online (Sandbox Code Playgroud)
您可以在http://jsfiddle.net/H5Qrh/1/中看到完整的代码
===更新===
我做了一个更干净的代码并尝试使用绝对居中而不是负边距:
.center-pane {
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
max-width: 277px;
height: 320px;
}
Run Code Online (Sandbox Code Playgroud)
我更新的小提琴:http://jsfiddle.net/H5Qrh/3/
现在页脚在盒子上方..不应该出现.
我正在评估将使用 docker-compose 的应用程序迁移到 Kubernates,并发现了两种解决方案:Kompose 和 compose-on-kubernetes。
我想知道它们在功能/易用性方面的差异,以便决定哪一个更适合。
我尝试使用 Swashbuckle.AspNetCore 5.0.0-rc2 和 4.0.1 在 Netcore 2.2 中创建 Webapi,问题是相同的。它在本地机器上工作,但是当我编译发布版本并部署到 IIS 时,我输入站点http://localhost/mysite/和错误:
未找到获取错误 /swagger/v1/swagger.json
此外,在浏览器中,如果我输入http://localhost/mysite/swagger/v1/swagger.json,我会在 OpenApi 中看到一个 Json。
非常简单的设置来重现:
公共类启动 { 公共启动(IConfiguration 配置){ 配置 = 配置;}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" …Run Code Online (Sandbox Code Playgroud) python ×4
python-3.x ×3
kubernetes ×2
.net ×1
c# ×1
cloud ×1
css ×1
debugging ×1
kubeadm ×1
linux ×1
migration ×1
mypy ×1
pip ×1
python-3.4 ×1
python-click ×1
swagger ×1
swashbuckle ×1
testing ×1
type-hinting ×1
unit-testing ×1
virtualenv ×1