How to install Python module on Ubuntu

爱⌒轻易说出口 提交于 2019-12-22 01:50:37

问题


I just wrote a function on Python. Then, I wanted to make it module and install on my Ubuntu 11.04. Here is what I did.

  1. Created setup.py along with function.py file.

  2. Built distribution file using $Python2.7 setup.py sdist

  3. Then installed it $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 '-------'

PS. I searched over google and didn't find particular answer. Detailed answer will be much appreciated.


回答1:


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

python2.7 setup.py install




回答2:


I could not install any modules or eggs until I used the package manager to install (for my version) 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. I assume python2.6-dev is the "development package".



来源:https://stackoverflow.com/questions/7426677/how-to-install-python-module-on-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!