14

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.

9
  • Are you trying to install to global python?. Then you need root permission for "$Python2.7 setup.py install" Commented Sep 15, 2011 at 7:13
  • I am trying to install on my local machine. Commented Sep 15, 2011 at 7:38
  • 1
    But do you have write permission to its lib?. Try "$which python2.7". If that shows /usr/bin/python2.7, you might need root access. Commented Sep 15, 2011 at 7:44
  • Are you sure the setup.py install command didn't error? You WILL need to call sudo for it to write the compiled modules to the python library directory in Ubuntu. Commented Sep 15, 2011 at 11:09
  • 1
    "Last line message is this". That's not 'site-packages'. Your code needs to be installed in site-packages. Please include the actual log with the actual commands and actual output in your question. Commented Sep 15, 2011 at 12:24

2 Answers 2

24

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

Sign up to request clarification or add additional context in comments.

Comments

3

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".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.