简体   繁体   English

如何在Ubuntu上安装Python模块

[英]How to install Python module on Ubuntu

I just wrote a function on Python. 我刚刚在Python上编写了一个函数。 Then, I wanted to make it module and install on my Ubuntu 11.04. 然后,我想在我的Ubuntu 11.04上创建模块并安装。 Here is what I did. 这就是我做的。

  1. Created setup.py along with function.py file. 创建setup.py以及function.py文件。

  2. Built distribution file using $Python2.7 setup.py sdist 使用$ Python2.7 setup.py sdist构建分发文件

  3. Then installed it $Python2.7 setup.py install 然后安装它$ Python2.7 setup.py install

All was going fine. 一切都很好。 But, later I wanted to use the module importing it on my code. 但是,后来我想在我的代码中使用模块导入它。 I got import error: ImportError: No module named '-------' 我收到导入错误:ImportError:没有名为'-------'的模块

PS. PS。 I searched over google and didn't find particular answer. 我搜索了谷歌并没有找到具体的答案。 Detailed answer will be much appreciated. 详细的答案将不胜感激。

Most installation requires: 大多数安装需要:

sudo python setup.py install

Otherwise, you won't be able to write to the installation directories. 否则,您将无法写入安装目录。

I'm pretty sure that (unless you were root), you got an error when you did 我很确定(除非你是root用户),你做错了

python2.7 setup.py install

I could not install any modules or eggs until I used the package manager to install (for my version) python2.6-dev 在我使用包管理器安装(对于我的版本)python2.6-dev之前,我无法安装任何模块或鸡蛋

 sudo apt-get install python2.6-dev

After that, I was able to run the setup.py file that was included in the downloaded and unpacked module without gcc errors. 之后,我能够运行包含在下载和解压缩模块中的setup.py文件,而不会出现gcc错误。 I assume python2.6-dev is the "development package". 我假设python2.6-dev是“开发包”。

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

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