0

I'm running a python script that originally worked fine before I upgraded my OSX to El Capitan. The problem I now have is ValueError: unichr() arg not in range(0x10000) (narrow Python build) occurs, which is caused by c = unichr(int(c, 16)). A similar post suggests that python 2.7 needs to be rebuilt to allow wider character ranges. I'd like to know the simplest way of doing this.

I understand that Python will probably need to be rebuilt and reconfigured to allow this. I notice numerous different Python installations in my /usr/bin, so before I go ahead and do any damage, does anybody have a step by step guide? Will rebuilding also affect the modules that are currently installed?

Community
  • 1
  • 1
D2J2
  • 63
  • 1
  • 9

2 Answers2

0

Use Homebrew's version of python rather than the python that OSX includes. That way you can stay current, won't get messed up if Apple decides to update, can use pip, ...

As a bonus you don't have to use sudo all the time; in fact Homebrew recommends against using sudo. Don't miss the El Capitan and Homebrew fixes

jwd630
  • 4,529
  • 1
  • 20
  • 22
  • Thanks. I do use homebrew, although I couldn't work out how to customise the installation of python through it to include wide character ranges. FYI, I've now fixed this by reinstalling on OSX, but it would be nice to know how to do it through homebrew. I know if you do a custom installation on OSX you just add the `--enable-unicode=ucs4` when executing `.\configure` – D2J2 Feb 05 '16 at 10:18
  • Well, I have not done it, but don't you want to just `brew uninstall python`; `brew edit python`; `brew install python`. The [FAQ](https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/FAQ.md#user-content-can-i-edit-formulae-myself) suggests so. – jwd630 Feb 05 '16 at 18:54
0

Despite having python 3.6 installed, things like ansible won't work because there is no python 2.7. easy_install won't work either. It seems like it needs to be reinstated to its original directory. Not only Home-brew would install it somewhere else, but, at this time, it isn't available anymore. I tried brew install python@2. It now says python@2 was deleted from homebrew/core in commit 028f11f9. It's not available even after git -C "$(brew --repo homebrew/core)" fetch --unshallow. Homebrew says in all fairness EOL 1 January 2020. We gave it 1 month more to live so that people had time to migrate. All in all, developers had 11 years to do their migration.

You must reinstate python 2.7 on your OSX by other means.

I went to the Time Machine backup via Finder and was able to reinstate some files on /Library/Python/2.7/site-packages/ and other locations. I filtered and copied files manually. It got things working.

Toani
  • 32
  • 4