Problems with installing Pip (python package manager)

Asked

Viewed 916 times

11

I use Mac OS and use HomeBrew as a package manager. I installed the python 2.7.10. Together with this installation was to have occurred the pip. However the following problem occurs:

==> /usr/local/Cellar/python/2.7.10/bin/python -s setup.py --no-user-cfg install --force
File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child raise child_exception
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128)

It seems that the problem is with the encoding. I made an attempt to edit the file subprocess.pyputting # -*- coding: utf-8 -*-, but to no avail. I also realized that the problem is not with the manager brew, because the same happened with the easy_install: File

"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1326, in _execute_child
raise child_exception
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128)

I wanted to use the /usr/local/lib/python2.7/site-package/ as directory for the python2.7 packages

  • How to resolve this @mgibsonbr? Got some idea?

  • 1

    Unfortunately, no. I’ve seen the previous question, but since I have no experience with Mac OS or Homebrew, I have no idea what it might be. I’ve never had this problem on Windows or Linux (the ones I’ve used pip).

  • This problem did not occur, but when I uninstalled Pip, because I believed I had problems with it, I could no longer install.

  • This error occurs when you try to install Python himself, or is it when installing a particular library or package? From what I’ve been reading around, this error is common when trying to encode or decode a string twice (i.e. from string to byte and again to byte, or from byte to string and again to string). It may be due to a programming error, but I can’t imagine it happening within Python itself... Maybe there was some mix of Python 2 and 3 code, I don’t know...

  • The error occurs in python installation via: brew install python and through the easy_install pip @mgibsonbr.

  • Yeah, I think only someone with Python experience on the Mac can help you, I’m totally in the dark... :(

  • 1

    I do not believe that there was a mixture of code. The pip3 works very well. It has been installing along with the python3 through Brew. However, as you well know, there are projects that only run on python 2x

  • There were 3 attempts: 1- using the brew during the installation of the python. 2- using the easy_install, system native. 3- downloading the Pip project from github running the python setup.py install. The problem is always the same, accusing in separate directories. In the first and third points to the /usr/local/... and in the second to /System/Libary/...

  • problems seem to be associated with subprocess.py

  • The raise child_exception gives me the impression that subprocess.py is only relaunching an exception that was generated elsewhere. This would indicate that the fault does not need to be exactly subprocess.py (and the encoding of that file). You can try for some prints in this region of the code to see what is happening. Another possibility is to use the strace (if you have it on OSX) to find out which files subprocess.py was trying to read before its error occurred.

Show 6 more comments

1 answer

1

I tried Ananconda, Homebrew and these just messed up my folder system. I like to control where my files are and recommend a much more practical and light recipe that I learned at MIT.

I use a Mac Book, and after many attempts and mistakes, I found that one should avoid to the maximum the latest versions of OS. So I downgraded the total of my mac (factory setting) from Yosemite to Montain Lion. This is the best way to put all the files in place and solve chronic errors. It costs almost a day, but then gain others.

This would be the first step of this "recipe", but is optional depending on the case. In mine, I could not plot any chart because anaconda and Homebrew create their folders and environments, apparently, there were different sudo and non-dsudo environments that I would take longer and it would be more boring than reinstalling everything.

But for a first experience of this recipe try:

1 - In terminal type: Python
Confirm: Python 2.7.2

2 - Write to the terminal quit() to quit Python

3 - Now type in the terminal: idle &
This generates an IDLE Python shell window outside the terminal and leaves the terminal and python independent.

4 - In the Python options from the main menu, you can configure in General how to open IDLE in Start Up, selected Open Text Edit. So when typing idle & you will open the editing program directly to read or write your code before running it. The shell you can open from the menu of this editor directly.

5 - Now, before step 6, make sure that the actual Python is not activated in the terminal by typing quit()

6 - In the terminal write easy_install pip (easy_install is a mac command installer)

7 - And after confirming the successful installation of Pip, write to the terminal sudo pip install pylab
pylab is the scientific python package that MIT students use, it includes matlibplot, netoworkx, numpy, etc.

8 - The rest you already know. In Python, use import pylab to use this resource.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.