Home:ALL Converter>Installing python modules on Ubuntu

Installing python modules on Ubuntu

Ask Time:2013-09-27T01:38:51         Author:Infamouslyuseless

Json Formatter

I need to install some modules for python on Ubuntu Linux 12.04. I want pygame and livewires but I'm not sure how to install them.

I have the py file for livewires, which has been specially edited (from a book I'm reading) and I want to install it but I'm not sure how to, I also want to install pygame.

Author:Infamouslyuseless,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/19034959/installing-python-modules-on-ubuntu
Fred Foo :

There are two nice ways to install Python packages on Ubuntu (and similar Linux systems):\n\nsudo apt-get install python-pygame\n\n\nto use the Debian/Ubuntu package manager APT. This only works for packages that are shipped by Ubuntu, unless you change the APT configuration, and in particular there seems to be no PyGame package for Python 3.\n\nThe other option is to use PIP, the Python package manager:\n\nsudo apt-get install python3-pip\n\n\nto install it, then\n\nsudo pip3 install pygame\n\n\nto fetch the PyGame package from PyPI and install it for Python 3. PIP has some limitations compared to APT, but it does always fetch the latest version of a package instead of the one that the Ubuntu packagers have chosen to ship.\n\nEDIT: to repeat what I said in the comment, pip3 isn't in Ubuntu 12.04 yet. It can still be installed with\n\nsudo apt-get install python3-setuptools\nsudo easy_install3 pip\nsudo apt-get purge python-pip\n\n\nAfter this, pip is the Python 3 version of PIP, instead of pip3. The last command is just for safety; there might be a Python 2 PIP installed as /usr/bin/pip.",
2013-09-26T17:44:55
user1525721 :

Try to install pip.\n\napt-get install python-pip\npip install pygame\n",
2013-09-26T17:45:43
Alvaro :

You can use several approaches:\n\n1 - Download the package by yourself. This is what I use the most. If the package follows the specifications, you should be able to install it by moving to its uncompressed folder and typing in the console:\n\npython setup.py build\npython setup.py install\n\n\n2 - Use pip. Pip is pretty straightforward. In the console, you have to type:\n\npip install package_name\n\n\nYou can obtain pip here https://pypi.python.org/pypi/pip and install it with method 1\n\nOne thing to note: if you aren't using a virtualenv, you'll have to add sudo before those commands (not recommended)",
2013-09-26T17:43:52
Roozbeh Bakhshi :

It depends on the Ubuntu version and the IDE you are using. \nUbuntu 15 and older come with Python 2.7 and Ubuntu 16.04 comes with both Python 2.7 and 3.5.\nNow based on the IDE you are using there are several ways to do this. Let`s say you only installed Spyder from Ubuntu app store or installed Jupyter. In other words you do not have a distribution like Anaconda or Enthought which install their own Python versions. This is important to pay attention to because once you are trying to install a package/library, you need to know which Python it is being installed to.\n\nNow assuming you just have an IDE that is connected to Ubuntu`s default Python versions, you can use the terminal to install your packages:\n\nFor python 2.7 use \n\npip install libraryname\n\n\nFor python 3.5 use\n\npip3 install libraryname\n\n\nSometimes, for reasons that I don`t know, during the package installation process, Linux blocks access to the Python so try these as well:\n\nsudo apt install python-libraryname\n\n\nand for Python 3.5\n\nsudo apt install python3-libraryname\n\n\nThese have helped me to install all the libraries that I need.\n\nNow, if you are using a distribution like Aanaconda or Enthought, there is a good chance that the libraries that you are installing are not going to be added to the libraries that those distributions use. In order to install the libraries for these distributions, once you run the distribution, go to the ipython console and write\n\n!pip install libraryname\n\n\nIn case of Enthought, it has it`s own Package Manager where it has most of the libraries you need and you can install them there without using pip or anything else. ",
2017-01-27T03:21:46
yy