EzDevInfo.com

pythonbrew

Python Environment manager

Is there a terminal command to find the path of libraries I installed with "brew install"?

Is there a terminal command to see the location of libraries I installed with brew install? I know they are in /usr/local, but I would like to see the whole path.

Thanks!


Source: (StackOverflow)

Can't install pythonbrew 2.6

I'm trying to install python 2.6 with pythonbrew but i received some error while running the command

pythonbrew install --configure="--enable-unicode=ucs4" 2.6

I'm running under Archlinux and used python2.7 for a long time on that machine. But I need to have both 2.6 and 2.7 on my machine so a pythonbrew install seemed ok.

Here is the error :

Parser/pgen ./Grammar/Grammar ./Include/graminit.h ./Python/graminit.c
Parser/pgen ./Grammar/Grammar ./Include/graminit.h ./Python/graminit.c
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude I./Include  -fPIC -DPy_BUILD_CORE -o Python/symtable.o Python/symtable.c
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include  -fPIC -DPy_BUILD_CORE -o Python/compile.o Python/compile.c
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include  -fPIC -DPy_BUILD_CORE -o Python/graminit.o Python/graminit.c
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include  -fPIC -DPy_BUILD_CORE -DSVNVERSION=\"`LC_ALL=C svnversion .`\" -o Modules/getbuildinfo.o ./Modules/getbuildinfo.c
gcc: error: directory": No such file or directory
make: *** [Modules/getbuildinfo.o] Error 1

Source: (StackOverflow)

Advertisements

How can I run a python script using pythonbrew venv from the command line?

I recently came across this in a cron script at my place of work:

/bin/bash -c "[[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.pythonbrew/etc/bashrc && pythonbrew use 2.6.7 && pythonbrew venv use someapp && python /opt/someapp/bin/someapp.py"

This is for a system-wide (multi-user) installation of Pythonbrew.

It works. But please tell me there's a better way.

Addendum

To clarify what I'm looking for: I'd like a one-line command to run my script though a virtualenv tied to pythonbrew. With virtualenv alone, I could do something like this:

/opt/someapp/venv/bin/python /opt/someapp/bin/someapp.py

What I don't want is another script to run my script (like that cron command above).


Source: (StackOverflow)

import zlib ImportError: No module named zlib

# pythonbrew venv create django1.5
Creating `django1.5` environment into /usr/local/pythonbrew/venvs/Python-2.7.3
Traceback (most recent call last):
File "/usr/local/pythonbrew/etc/virtualenv/virtualenv.py", line 19, in <module>
import zlib
ImportError: No module named zlib

What should I do?? I want to import zlib.

And I aready install zlib *

# rpm -qa |grep zlib
zlib-1.2.5-7.fc17.i686
zlib-devel-1.2.5-7.fc17.i686

UPDATE:

# uname -a
Linux localhost.localdomain 3.6.10-2.fc17.i686 #1 SMP Tue Dec 11 18:33:15 UTC 2012 i686 i686 i386 GNU/Linux
# cat /etc/issue
Fedora release 17 (Beefy Miracle)
Kernel \r on an \m (\l)

Source: (StackOverflow)

How to build pgmagick under pythonbrew on OS X?

I'm not having much success when attempting building pgmagick on OS X Lion with XCode 4.3.1.

I've installed both ImageMagick and GraphicsMagick, along side boost, using the following commands (via homebrew):

$ brew install graphicsmagick --with-magick-plus-plus
$ brew install imagemagick --with-magick-plus-plus
$ brew install boost --with-thread-unsafe

then I'm cloning the repo at https://bitbucket.org/hhatto/pgmagick:

$ hg clone https://bitbucket.org/hhatto/pgmagick/src
$ cd pgmagick
$ python setup.py build

However I always receive the following error:

ld: library not found for -lboost_python
collect2: ld returned 1 exit status

Based on the output on stdout, setup is looking in the right place for the boost (/usr/local/lib).

I've also tried easy_install and pip but with no luck. I'm using Pythonbrew but have also disabled this and tried using the stock python install -- still no success.

Any suggestions on how I can fix the problem, or further diagnose the issue?


Source: (StackOverflow)

python: what's the difference between pythonbrew and virtualenv?

I am new to python and I am planning to learn django. I had a bit of experience with ruby (not rails) and I am familiar with RVM however I don't understand the difference between pythonbrew and virtualenv. I know pythonbrew is a mimic of RVM but I thought virtualenv is already doing what RVM does (or vice versa that pythonbrew is already doing what RVM does). Can someone please explain and perhaps provide some concrete examples/usages to help me understand it. Thanks very much!


Source: (StackOverflow)

Pythonbrew install ZSH on Ubuntu

Can anyone shed any light on how to have pythonbrew / pythonz install when my shell is ZSH. I am on ubuntu 12.04.

I have followed the standard install of curl and then adding the line to ~/.bashrc but it will return an unknown command in a new zsh terminal.

[[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.pythonbrew/etc/bashrc

PythonBrew Readme


Source: (StackOverflow)

pythonbrew bashrc awk line no longer works

I recently upgraded my FreeBSD box and now pythonbrew seems to be broken. It bails out of the .pythonbrew/etc/bashrc file on this line:

PATH_WITHOUT_PYTHONBREW=$(printf "$PATH" | awk -v RS=: -v ORS=: "/${PATH_ROOT//\//\/}/ {next} {print}" | sed -e 's#:$##')

Gives the error:

awk: syntax error at source line 1
   context is
      >>> //home/myusername/. <<< pythonbrew/ {next} {print}
awk: bailing out at source line 1

That PATH_ROOT variable is

/home/myusername/.pythonbrew

Source: (StackOverflow)

Pythonbrew issue

I have installed pythonbrew on my CentOS so that i can use the latest version of python (python2.7) without touching the base installation which comes with CentOS. The problem is that when installing any packages like "for eg. requests" with easy_install and with pip then it is getting installed to the base python which is python2.6.

Long story short i want easy_install and pip to work with python2.7 and not with the base python. Please help me

easy_install requests

Searching for requests Best match: requests 2.7.0 Processing requests-2.7.0-py2.6.egg requests 2.7.0 is already the active version in easy-install.pth

Using /usr/lib/python2.6/site-packages/requests-2.7.0-py2.6.egg Processing dependencies for requests Finished processing dependencies for requests


Source: (StackOverflow)

pythonbrew with mod_wsgi

pythonbrew isn't getting picked up by by mod_wsgi file, config follows:

import os
import sys
import site

site.addsitedir('/home/bharal/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages')
sys.path.append ('/home/bharal/public_html/dumpstown')

os.environ['DJANGO_SETTINGS_MODULE'] = 'dumpstown.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

and the pythonbrew version of python i want to use is situated here:

/home/bharal/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages

and my pythonbrew install is here:

/home/bharal/.pythonbrew/

How do i tell mod_wsgi to use this version (2.7.2) and not the default python version that shipped with ubuntu (2.6)?

When i run my server, i get errors like so:

[Wed Jul 04 02:17:27 2012] [error] [client 127.0.0.1] mod_wsgi (pid=18694): Exception occurred processing WSGI script '/home/bharal/public_html/dumpstown/dumpstown/apache/dumpstown.wsgi'.
[Wed Jul 04 02:17:27 2012] [error] [client 127.0.0.1] Traceback (most recent call last):
[Wed Jul 04 02:17:27 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 250, in __call__
[Wed Jul 04 02:17:27 2012] [error] [client 127.0.0.1]     self.load_middleware()
[Wed Jul 04 02:17:27 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 39, in load_middleware
[Wed Jul 04 02:17:27 2012] [error] [client 127.0.0.1]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Wed Jul 04 02:17:27 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py", line 276, in __getattr__
[Wed Jul 04 02:17:27 2012] [error] [client 127.0.0.1]     self._setup()
[Wed Jul 04 02:17:27 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 42, in _setup
[Wed Jul 04 02:17:27 2012] [error] [client 127.0.0.1]     self._wrapped = Settings(settings_module)
[Wed Jul 04 02:17:27 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 89, in __init__
[Wed Jul 04 02:17:27 2012] [error] [client 127.0.0.1]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Wed Jul 04 02:17:27 2012] [error] [client 127.0.0.1] ImportError: Could not import settings 'dumpstown.settings' (Is it on sys.path?): No module named gravatar.templatetags

as you can see from the logs, the server is still looking at python 2.6!! Why? I've kicked off pythonbrew so when i type in python i can see the version is 2.7.2, and all the settings and packages i need are importable!

UPDATE as indicated in the answer below, the mod_wsgi doesn't care which python i tell it to use - in fact, i cannot tell it to use any particular python. The only way to do so is to download an uncompiled wsgi file, compile with the particular python version i want, and use the compiled wsgi.

See my other question Error: Command failed with rc=65536 python and mod_wsgi for some of the steps and links to tutes if you like. In the end i didn't compile against 2.7 (my 2.6 was fine and it was too hard to get the pythonbrew compile working)


Source: (StackOverflow)

Use interactive python in pythonbrew

I installed pythonbrew and then switch to python3.2.

$pythonbrew install 3.2 
$pythonbrew switch 3.2

Then I found I couldn't run python interactively:

$python
Usage: /home/raincole/.pythonbrew/pythons/Python-3.2/bin/python [--prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags]

Am I really using python 3.2? I can't even run python --version to see what I'm doing.


Source: (StackOverflow)

Manage python version in different virtualenv with pythonbrew

My main system python version is 2.7.3. I'm trying to create a virtualenv that uses version 3.3.0. I installed pythonbrew, virtualenv and virtualenvwrapper.

I followed this tutorial: http://technomilk.wordpress.com/2011/07/27/setting-up-our-django-site-environment-with-pythonbrew-and-virtualenv/

Which essentially runs pythonbrew use 3.3.0, and then create a virtualenv. The tutorial says that the virtualenv will use the version pythonbrew uses. But it doesn't. The virtualenv uses 2.7.3 when I start it. When I do pythonbrew use 3.3.0, it leaves the virtualenv and it applies to the system instead of the environment.

Apparently, pythonbrew has its own virtualenv wrapper, which has a tutorial at: http://suvashthapaliya.com/blog/2012/01/sandboxed-python-virtual-environments/

I hate doing it like that though. Is it possible to use virtualenvwrapper along with pythonbrew (and not pythonbrew's venv wrapper) to be able to choose which python version to use for each venv, and keep them separate from the system python version?

Also, I do not want to use mkvirtualenv -p flag, as this means I need to manually install python3.3. I'd rather stick to using a package manager to manage python versions. It's hard to believe that nothing in python equates to RVM in ruby... Unless I'm mistaken?


Source: (StackOverflow)

Install multiple python versions

I would like to install several python versions to build SymPy with Sympy-bot in my fedora 18. I came to know that pythonbrew can be used to do that from here. I followed the installation instructions but when I try to install a python version, pythonbrew downloads the source package and start installing it. Before the completion it exits with the below error message.

Patching Python-2.5 ERROR: Failed to patch /home/thilina/.pythonbrew/build/Python-2.5. 127: failed to (patch -p0 < "/home/thilina/.pythonbrew/patches/all/python25/patch-setup.py.diff") >> '/home/thilina/.pythonbrew/log/build.log' 2>&1

Can anyone lend me a hand here? Thanks in advance.


Source: (StackOverflow)

brew install python - fails OSX

Im trying to install python through brew with:

brew install python  

But get the following error:

Stevens-MacBook-Pro :: ~ ‹master*› » brew install python
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/python-2.7.
Already downloaded: /Library/Caches/Homebrew/python-2.7.8_2.mountain_lion.bottle.tar.gz
==> Pouring python-2.7.8_2.mountain_lion.bottle.tar.gz
==> Caveats
Setuptools and Pip have been installed. To update them
  pip install --upgrade setuptools
  pip install --upgrade pip

You can install Python packages with
  pip install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: https://github.com/Homebrew/homebrew/wiki/Homebrew-and-Python

.app bundles were installed.
Run `brew linkapps` to symlink these to /Applications.
/usr/bin/install_name_tool: object: /usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python malformed object (unknown load command 10)
Error: Failed to fix install names
The formula built, but you may encounter issues using it or linking other
formula against it.
==> /usr/local/Cellar/python/2.7.8_2/bin/python -ssetup.py --no-user-cfg instal
  using one of the approaches described here:

Please make the appropriate changes for your system and try again.
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall python`
==> Summary
🍺  /usr/local/Cellar/python/2.7.8_2: 4626 files, 73M

The error messages says the post install fails, and to try installing it again with:

brew postinstall python

but the error still persists. I also tried brew linkapps and it success fully links python but when I run pip from the console I get this error:

Stevens-MacBook-Pro :: ~ ‹master*› » pip
zsh: /usr/local/bin/pip: bad interpreter: @@HOMEBREW_PREFIX@@/opt/python/bin/python2.7: no such file or directory

Any idea what might be going wrong?


Source: (StackOverflow)

Using Ansible, how can I install PythonBrew system-wide?

I'm trying to create a playbook with Ansible (v 1.3.3) to install Pythonbrew system-wide on a Debian server following the instructions in the Pythonbrew readme file.

I am able to get Pythonbrew installed but I cannot install the specific version of Python that I want with it. I suspect the issue has to do with the shell environment Ansible is running under.

Here's my playbook script:

- name: Install and configure PythonBrew
  hosts: dev
  user: root
  vars_files:
    - vars.yml
  gather_facts: false

  tasks:
    - name: Install PythonBrew Debian packages
      apt: pkg=${item} state=installed update-cache=yes
      with_items: ${pythonbrew_packages}

    - name: Install PythonBrew system-wide
      shell: curl -kL http://xrl.us/pythonbrewinstall | bash creates=/usr/local/pythonbrew executable=/bin/bash

    - name: Update bashrc for PythonBrew
      lineinfile:
        dest=~/.bashrc
        regexp='^'
        line='[[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.pythonbrew/etc/bashrc'
        state=present
        create=True

    - name: Install python binary
      shell: pythonbrew install -v ${python_version} executable=/bin/bash

When I run this playbook, it fails with the following output

failed: [devserver] => {"changed": true, "cmd": "pythonbrew install -v 2.7.3 ", "delta": "0:00:00.016639", "end": "2013-10-11 15:21:40.989677", "rc": 127, "start": "2013-10-11 15:21:40.973038"} stderr: /bin/bash: pythonbrew: command not found

I've been tweaking things for the last hour or so to no avail. Does anybody have any suggestions for fixing this?


Source: (StackOverflow)