如何安装matplotlib? [蟒蛇]

时间:2018-06-02 10:10:10

标签: python ubuntu matplotlib cryptography pip

当我想通过pip安装matplotlib时遇到问题:
我做了:

$ sudo pip install matplotlib

出:

Requirement already satisfied: matplotlib in /usr/lib/python2.7/dist-packages (1.5.1)
launchpadlib 1.10.3 requires testresources, which is not installed.
paramiko 2.4.1 has requirement cryptography>=1.5, but you'll have cryptography 1.2.3 which is incompatible.

然后我做了:

$ sudo pip install cryptography

Out:与上述相同的错误。

部分代码:

import sys
print(sys.version)
import matplotlib.pyplot as plt

出:

2.7.12 (default, Dec  4 2017, 14:50:18) 
Traceback (most recent call last):
[GCC 5.4.0 20160609]

import matplotlib.pyplot as plt
ImportError: No module named matplotlib.pyplot

我该怎么办?

提前致谢。

1 个答案:

答案 0 :(得分:1)

我发现了问题:

我使用了 Pycharm IDE并创建了一个新项目并选择“使用Vitualenv的新环境”选项而不是“现有解释器”,然后我将其更改为“现有解释器”选项,这是正确的。

感谢我的问题中的所有评论(更新type Thing = | { type: 'a', a: 1 } | { type: 'a', a: 2 } | { type: 'b', b: 3 } | { type: 'b', b: 4 } | { type: 'c', c: 5 } | { type: 'c', c: 6 } function printThing (thing: Thing): void { switch (thing.type) { case 'a': console.log(thing.a); break; // fails, can't be a c field if type is 'b' case 'b': console.log(thing.c); break; // fails, can't be an a field if type is 'c' case 'c': console.log(thing.a); break; } } printThing({ type: 'a', a: 1 }) // what type do I give thingOfTypeA so that flow refines Thing // to only the options with type 'a', like in the case 'a': statement? // // e.g. Hypothetical syntax: (thingOfTypeA: Thing extends { type: 'a' }) // function printThingOfTypeA (thingOfTypeA: Thing) { // this is fine as all have a type console.log('type: ' + thingOfTypeA.type) // how can this 'know' that I've passed a thing of type 'a' // so that it doesn't fail? console.log('a: ' + thingOfTypeA.a) } 并关注 Python 版本)。