Search code examples
pythondjangopipeasy-install

Issues in Installing Python packages in webfaction


I am trying to install packages using PIP but it doesn't work for me initially it gives the permission denied error and after that when I tried to use easy_install it gives me this error :->

 Searching for mezzanine
    Reading https://pypi.python.org/simple/mezzanine/
    Reading http://github.com/stephenmcd/mezzanine/
    Reading http://mezzanine.jupo.org/
    Best match: Mezzanine 3.1.8
    Downloading https://pypi.python.org/packages/source/M/Mezzanine/Mezzanine-3.1.8.tar.gz#md5=dcc46016b866ea8de1c87fb9dffd9163
    Processing Mezzanine-3.1.8.tar.gz
    Writing /tmp/easy_install-2cSSS_/Mezzanine-3.1.8/setup.cfg
    Running Mezzanine-3.1.8/setup.py -q bdist_egg --dist-dir /tmp/easy_install-2cSSS_/Mezzanine-3.1.8/egg-dist-tmp-uDjreS
    Traceback (most recent call last):
      File "/usr/local/bin/easy_install", line 8, in ?
        sys.exit(
      File "/usr/local/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1924, in main
        with_ei_usage(lambda:
      File "/usr/local/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1911, in with_ei_usage
        return f()
      File "/usr/local/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1928, in <lambda>
        distclass=DistributionWithoutHelpCommands, **kw
      File "/usr/local/lib/python2.4/distutils/core.py", line 149, in setup
        dist.run_commands()
      File "/usr/local/lib/python2.4/distutils/dist.py", line 946, in run_commands
        self.run_command(cmd)
      File "/usr/local/lib/python2.4/distutils/dist.py", line 966, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 374, in run
        self.easy_install(spec, not self.no_deps)
      File "/usr/local/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 609, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/usr/local/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 639, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/usr/local/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 825, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/usr/local/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1031, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/usr/local/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1016, in run_setup
        run_setup(setup_script, args)
      File "/usr/local/lib/python2.4/site-packages/setuptools/sandbox.py", line 68, in run_setup
        DirectorySandbox(setup_dir).run(
      File "/usr/local/lib/python2.4/site-packages/setuptools/sandbox.py", line 120, in run
        return func()
      File "/usr/local/lib/python2.4/site-packages/setuptools/sandbox.py", line 71, in <lambda>
        {'__file__':setup_script, '__name__':'__main__'}
      File "setup.py", line 22
        with open(e, "r") as f:
                ^
    SyntaxError: invalid syntax

After this when I again try to use pip then I am getting different error (not permission denied) :

 File "/home/rishi/bin/pip", line 8, in ?
    sys.exit(
  File "/usr/local/lib/python2.4/site-packages/pkg_resources.py", line 357, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python2.4/site-packages/pkg_resources.py", line 2394, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python2.4/site-packages/pkg_resources.py", line 2108, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/home/rishi/lib/python2.4/pip-1.5.6-py2.4.egg/pip/__init__.py", line 9, in ?
    from pip.log import logger
  File "/home/rishi/lib/python2.4/pip-1.5.6-py2.4.egg/pip/log.py", line 19
    real_consumer = (consumer if not isinstance(consumer, colorama.AnsiToWin32)
                               ^
SyntaxError: invalid syntax

Now I don't know what I am doing wrong , can anybody help me ?

EDIT :- syntex errro solved due to wrong python version , I was using 2.4 .

OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/mezzanine'

$which pip result is

~/bin/pip

Solution

    • as Daniel Roseman noted - the syntax error came from using Python2.4
    • the permission problem is caused by trying to install into system Python, what requires sudo or being root

    Possible solutions

    Install into system Pyhton (using sudo)

    $ sudo pip install mezzanine
    

    This will spoil the system Python and is not much recommended. It would be well acceptable if you are e.g. under Docker.

    Install into user profile

    $ pip install --user mezzanine
    

    It will install the package into user scheme and will not spoil system Python.

    This is more acceptable, but can soon become messy environment to run code in, as Python will import form user scheme, sometime from system.

    Use virtualenv

    Assuming you have virtualenv installed:

    $ cd ~/projects
    $ mkdir mezza
    $ cd mezza
    $ virtualenv venv
    $ source venv/bin/activate
    (venv)$ pip install mezzanine
    $ pip freeze
    mezzanine==3.1.8
    

    (there will be a bit more lines from freeze).

    This installs into virtualenv, which is easy to recreate, destroy, and does not mess up with other environments.

    With virtulanevwrapper you will get set of additional tools, which will simplify your environment a lot.