Installing Python Packages

python

#1

Cloud9 supports the installation of Python packages for applications that need to go beyond the standard library set. Every workspace has version 0.6.10 of Python’s easy_install package manager. For more information on this module, see the official easy_install documentation.

Let’s try installing a package. First, type the following in the console:

sudo easy_install markdown

easy_install Requires Sudo
Be sure to use sudo. If you do not, you will get a “permission denied” error.

This installs the markdown Python package to your workspace. You won’t see the package installed in the directory tree, because it’s kept deep within your project’s Python libs.

Next, create a new Python script, and add these lines of code:

import markdown

html = markdown.markdown("# HELLO THERE!")

print html

After clicking run, the console will correctly print out <h1>HELLO THERE!</h1>.

You have access to all of the functionality easy_install provides you. For example, you can open up the Python REPL and type the following to see a list of your installed packages:

>>> help('modules')

Python modules not importing / installing packages
Tutorials - Table of Contents
#2

Mysteriously, this seems to fail when claiming to succeed? I asked it to install the OpenCV cv2 module:

joker_b:~/workspace (master) $ sudo easy_install cv2
Searching for cv2
Reading https://pypi.python.org/simple/cv2/
Best match: cv2 1.0
Downloading https://pypi.python.org/packages/source/c/cv2/cv2-1.0.zip#md5=ceb8186537cd276c6d269672350f9e64
Processing cv2-1.0.zip
Writing /tmp/easy_install-1PRS_F/cv2-1.0/setup.cfg
Running cv2-1.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-1PRS_F/cv2-1.0/egg-dist-tmp-FGYbLT
zip_safe flag not set; analyzing archive contents...
Adding cv2 1.0 to easy-install.pth file

Installed /usr/local/lib/python2.7/dist-packages/cv2-1.0-py2.7.egg
Processing dependencies for cv2
Finished processing dependencies for cv2

but then

joker_b:~/workspace (master) $ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>> exit()

and checking help('modules') doesn’t show cv2 either


#3

And you get the same functionality when you call it from an actual Python script as well?


#4

Sadly, yes.

Traceback (most recent call last):                                                                                                
  File "/home/ubuntu/workspace/python/facematch.py", line 10, in <module>                                                         
    import cv2                                                                                                                    
ImportError: No module named cv2

#5

Is there any way to get pygame?


#6

Should work without any issues. You may need to use the desktop GUI plugin to get it working.


#7

Trying to install pycurl with “sudo easy_install pycurl”, but I get this error during the script:

main.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory