如何在Ubuntu16.04中安装pylab?

2024-10-01 07:35:41 发布

您现在位置:Python中文网/ 问答频道 /正文

(GWAVA) wangshx@wangshx-KVM:~/GWAVA_v1.0/src$ python gwava_paper.py Traceback (most recent call last): File "gwava_paper.py", line 19, in <module> from gwava import * File "/home/wangshx/GWAVA_v1.0/src/gwava.py", line 21, in <module> import pylab as pl ImportError: No module named pylab 如何安装pylab模块,我搜索它,发现它是matplotlib的一部分,但我不知道应该安装matplotlib的哪个版本。我尝试安装最新的版本,它提醒我更新许多模块版本。但我需要控制模块的版本。在

当我运行别人编写的python脚本时,我通过使用Anaconda创建一个新环境来控制模块版本。在

这是脚本文档。在

The software requires the following python libraries (and their 
associated dependencies) to be installed. The version numbers used
are identified, other versions may also work, but results may be 
slightly different.

- numpy (1.7.0)
- scipy (0.11.0)
- pandas (0.12.0)
- scikit-learn (0.14.1)
- pybedtools (0.6.4)
- tabix (0.2.5)

我在README中安装了所有模块。在

^{pr2}$

有什么帮助吗?在


Tags: 模块inpyimport版本srcmatplotlibline
2条回答

virtualenv是避免Python库版本控制问题的常用方法。在

根据文件:

virtualenv is a tool to create isolated Python environments.

The basic problem being addressed is one of dependencies and versions, and indirectly permissions. Imagine you have an application that needs version 1 of LibFoo, but another application requires version 2. How can you use both these applications? If you install everything into /usr/lib/python2.7/site-packages (or whatever your platform’s standard location is), it’s easy to end up in a situation where you unintentionally upgrade an application that shouldn’t be upgraded.

Or more generally, what if you want to install an application and leave it be? If an application works, any change in its libraries or the versions of those libraries can break the application.

我使用conda search matplotlib来查找matplotlib的所有版本。在

          1.2.1                np17py33_0  defaults        
                         1.2.1                np16py26_1  defaults        
                         1.2.1                np16py27_1  defaults        
                         1.2.1                np17py26_1  defaults        
                         1.2.1                np17py27_1  defaults        
                         1.2.1                np17py33_1  defaults        
                         1.3.0                np16py26_0  defaults        
                         1.3.0                np16py27_0  defaults        
                         1.3.0                np17py26_0  defaults        
                         1.3.0                np17py27_0  defaults        
                         1.3.0                np17py33_0  defaults        
                         1.3.1                np16py26_0  defaults        
                         1.3.1                np16py27_0  defaults        
                         1.3.1                np17py26_0  defaults        
                         1.3.1                np17py27_0  defaults        
                         1.3.1                np17py33_0  defaults 

然后选择一个似乎支持numpy17的版本(如1.3.0)。它在安装matplotlib的1.3.0版本之后就可以工作了!在

相关问题 更多 >