简体   繁体   English

如何在Ubuntu16.04中安装pylab?

[英]How to install pylab in Ubuntu16.04?

(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 How can I install pylab module, I search it and find that it is a part of matplotlib , but I don't know which version of matplotlib I should install. (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 I try to install the newest version, it reminds me to update many module version. 我尝试安装最新版本,它提醒我更新许多模块版本。 But I need to control the version of modules. 但是我需要控制模块的版本。

When I run a python scripts written by others, I controlled module version by creating a new environment using Anaconda . 当我运行别人编写的python脚本时,我通过使用Anaconda创建新环境来控制模块版本。

This is the scripts documentation. 这是脚本文档。

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)

I installed all module in the README . 我在README安装了所有模块。

(GWAVA) wangshx@wangshx-KVM:~/GWAVA_v1.0/src$ conda list
dateutil                  2.4.1                    py27_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
libgfortran               1.0                           0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
mkl                       2017.0.1                      0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
nose                      1.3.7                    py27_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
numpy                     1.7.0                    py27_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
openssl                   1.0.2l                        0    defaults
pandas                    0.12.0               np17py27_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pip                       9.0.1                    py27_1    defaults
pybedtools                0.6.4                     <pip>
python                    2.7.13                        0    defaults
python-dateutil           2.6.0                    py27_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pytz                      2017.2                   py27_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
readline                  6.2                           2    defaults
scikit-learn              0.14.1               np17py27_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
scipy                     0.11.0               np17py27_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
setuptools                27.2.0                   py27_0    defaults
six                       1.10.0                   py27_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
sqlite                    3.13.0                        0    defaults
tabix                     1.0                       <pip>
tk                        8.5.18                        0    defaults
wheel                     0.29.0                   py27_0    defaults
zlib                      1.2.8                         3    defaults

Any help? 有什么帮助吗?

virtualenv is the usual way to avoid the library versioning problem with Python. virtualenv是避免Python版本库问题的常用方法。

From the documentation: 从文档中:

virtualenv is a tool to create isolated Python environments. virtualenv是用于创建隔离的Python环境的工具。

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? 假设您有一个需要使用LibFoo版本1的应用程序,但是另一个应用程序需要版本2。您如何同时使用这两个应用程序? 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. 如果将所有内容都安装到/usr/lib/python2.7/site-packages(或平台的标准位置是什么)中,那么很容易在无意中升级不应升级的应用程序的情况下结束。

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. 如果应用程序正常运行,则其库或这些库的版本中的任何更改都可能破坏该应用程序。

I use conda search matplotlib to find all the version of matplotlib . 我用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 

And choose one version (such as 1.3.0) that seems support the numpy17 . 然后选择一个似乎支持numpy17版本(例如1.3.0)。 It works after installing 1.3.0 version of matplotlib ! 在安装1.3.0版本的matplotlib之后,它可以工作!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM