1
votes

I wanted to install twisted on my Mint Linux 17 machine. I downloaded the source file (from here). I extracted the contents into a folder, changed to that folder and ran the following commands to install the library.

$ python setup.py build
$ sudo python setup.py install

I had to use sudo for the second command, because I could not get it to work without sudo.

Everything was installed without any problem, but when I try to run a sample code I got a import error.

$ python datagram.py                  
Traceback (most recent call last):
  File "datagram.py", line 3, in <module>
    from twisted.internet.protocol import DatagramProtocol
ImportError: No module named twisted.internet.protocol

But it works when I run the same with sudo.

$ sudo python datagram.py

Why is this happening? What do I need to fix to get twisted programs running without the need for sudo?

1
does which python and sudo which python differ? You should opt for virtualenv, that would solve your problem for good. - brunsgaard

1 Answers

2
votes

sudo setup.py install is one of the ways to screw up your installation of Python and its libraries. Other members of the club include sudo easy_install <package> and sudo pip install <package>.

If you want to do a system-wide installation of a Python library (or any piece of software, probably): use your system package manager.

If you want to install a version of a Python library different from the version available from your system package manager, use virtualenv and install the library into that.