python - How to use BeautifulSoup after installing from MacPorts?

06
2014-04
  • Imran

    I installed BeautifulSoup @3.2.1_0 via port install py27-beautifulsoup. Now how do i use it?

    I tried the following from the python console:

    >>>> from py27-beautifulsoup import BeautifulSoup
      File "<stdin>", line 1
        from py27-beautifulsoup import BeautifulSoup
                 ^
    SyntaxError: invalid syntax
    

    and

    >>>> from BeautifulSoup import BeautifulSoup
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named BeautifulSoup
    

    In general is there a way to know the command to run an installed package? It doesn't always match the package name as far as I can tell. I have had this problem before, like with g++ for example.

    EDIT

    I installed BeautifulSoup4 via pip install beautifulsoup4, and now this works:

    from bs4 import BeautifulSoup
    
  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    python - To install Gaphor by Easy_install and its dependencies by MacPorts
  • Masi

    I seem to install Gaphor successfully by Easy_install

    $ sudo easy_install gaphor
    Searching for gaphor
    Best match: gaphor 0.14.0
    Processing gaphor-0.14.0-py2.5.egg
    gaphor 0.14.0 is already the active version in easy-install.pth
    Installing gaphorconvert script to /usr/local/bin
    Installing gaphor script to /usr/local/bin
    
    Using /Library/Python/2.5/site-packages/gaphor-0.14.0-py2.5.egg
    Processing dependencies for gaphor
    Finished processing dependencies for gaphor
    

    I run it unsuccessfully by

    $ gaphor
    Traceback (most recent call last):
      File "/usr/local/bin/gaphor", line 8, in <module>    load_entry_point('gaphor==0.14.0', 'console_scripts', 'gaphor')()
      File "/Library/Python/2.5/site-packages/gaphor-0.14.0-py2.5.egg/gaphor/__init__.py", line 65, in main    launch()
      File "/Library/Python/2.5/site-packages/gaphor-0.14.0-py2.5.egg/gaphor/__init__.py", line 36, in launch    from gaphor.application import Application
      File "/Library/Python/2.5/site-packages/gaphor-0.14.0-py2.5.egg/gaphor/application.py", line 16, in <module>    import gaphor.UML
      File "/Library/Python/2.5/site-packages/gaphor-0.14.0-py2.5.egg/gaphor/UML/__init__.py", line 3, in <module>
        from gaphor.UML.uml2 import *
      File "/Library/Python/2.5/site-packages/gaphor-0.14.0-py2.5.egg/gaphor/UML/uml2.py", line 97, in <module>
        from diagram import Diagram
      File "/Library/Python/2.5/site-packages/gaphor-0.14.0-py2.5.egg/gaphor/UML/diagram.py", line 12, in <module>    import gobject
    ImportError: No module named gobject
    

    I then install gobject and run sudo port install py26-gobject. However, the same problem persists.

    How can you install Gaphor to OS X by MacPorts?


  • Related Answers
  • Mike McQuaid

    You are missing GObject for Python 2.5.

    Run:

    sudo port install py25-gobject
    

    Gaphor should work after this.

  • redacted

    You didn't install with MacPorts, you installed with the system Python install.

    instead, try

    sudo /opt/local/bin/easy_install gaphor
    

    As Mike said you may need support libraries installed with macports