小编Edw*_*ric的帖子

Matplotlib 不适用于 Linux。无法加载后端“TkAgg”

尝试在 Linux 上使用 Matplotlib,但我不断收到此错误:

ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'headless' is currently running
Run Code Online (Sandbox Code Playgroud)

我在操作系统上使用虚拟环境:Linux 18.04 LTS。Python版本:3.6

我尝试了许多其他帖子建议的解决方案:

sudo apt-get install tk-dev libpng-dev libffi-dev dvipng texlive-latex-base
pip uninstall matplotlib
pip --no-cache-dir install matplotlib
Run Code Online (Sandbox Code Playgroud)

我试过摆弄使用 matplotlib 的 python 脚本:

#TOP OF FILE
import matplotlib
matplotlib.use('Agg') # or 'TkAgg', or removing the line altogether
import matplotlib.pyplot as plt
...
Run Code Online (Sandbox Code Playgroud)

运行 python 以查看正在使用的后端:

import matplotlib
matplotlib.get_backend()   # -> 'agg'
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?谢谢

python linux matplotlib

7
推荐指数
1
解决办法
4114
查看次数

使用flexbox水平居中内容

我正在努力将我的容器中的一些内容水平居中:

https://jsfiddle.net/y56t31q9/6/

.container {
  display: flex;
  flex-direction: column;
  width: 600px;
  background-color: blue;
  justify-content: center;
  /* Not centering content horizontally? */
}
.item {
  max-width: 500px;
  height: 100px;
  background-color: yellow;
  border: 2px solid red;
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
  <div class="item"></div>
  <section class="item"></section>
  <section class="item"></section>
  <footer class="item"></footer>
</div>
Run Code Online (Sandbox Code Playgroud)

我本以为是合理的 - 内容会成功,但无济于事.

任何帮助将不胜感激谢谢!

html css alignment css3 flexbox

6
推荐指数
1
解决办法
2706
查看次数

Python:while循环的非常基本的帮助

我到处寻找我的问题的答案,我仍然无法弄清楚!答案可能很简单,但我无法得到它,也许是因为我刚回到Python ...

无论如何,我想创建一个while循环,这样在用户输入"y"或"n"之前,问题将继续被问到.这就是我所拥有的:

while True:   # to loop the question
    answer = input("Do you like burgers? ").lower()
    if answer == "y" or "n":
        break 
Run Code Online (Sandbox Code Playgroud)

说实话,我真是太困惑了,所以我求求别人的帮助:)

python while-loop

3
推荐指数
1
解决办法
76
查看次数

标签 统计

python ×2

alignment ×1

css ×1

css3 ×1

flexbox ×1

html ×1

linux ×1

matplotlib ×1

while-loop ×1