This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: platform.py line _sys_version function
Type: crash Stage:
Components: Library (Lib) Versions: 3rd party
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: lemburg, ned.deily, wesmadrigal
Priority: normal Keywords:

Created on 2013-12-18 23:08 by wesmadrigal, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (12)
msg206560 - (view) Author: Wes (wesmadrigal) Date: 2013-12-18 23:08
Marc-Andre,
I'm on a Macbook pro OSX Mountain Lion

I've been automating virtual environment builds locally and remotely, but it seems that when my "pip install -r requirements.txt" tries to run and download.py in pip/ runs it invokes "platform.py".  I'm getting a user-agent issue from the _sys_version function.  Here is the error:



  File "/Users/me/anaconda/lib/python2.7/platform.py", line 1500, in python_implementation
    return _sys_version()[0]

  File "/Users/me/anaconda/lib/python2.7/platform.py", line 1464, in _sys_version
    repr(sys_version))
ValueError: failed to parse CPython sys.version: '2.7.5 (default, Sep 12 2013, 21:33:34) \n[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]'


I've found the following stack that also references this error:

http://stackoverflow.com/questions/19105255/praw-failed-to-parse-cpython-sys-version-when-creating-reddit-object
msg206561 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2013-12-18 23:17
I have tried this with a stock Python 2.7.6 version and don't get an error:

>>> platform._sys_version('2.7.5 (default, Sep 12 2013, 21:33:34) \n[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]')
('CPython', '2.7.5', '', '', 'default', 'Sep 12 2013 21:33:34', 'GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)')

The stackoverflow posting you mentioned obviously uses a Python version that was modified in incompatible ways, so it doesn't apply here.

Are you running an Apple version of Python or one that was installed using the python.org installer ?
msg206562 - (view) Author: Wes (wesmadrigal) Date: 2013-12-18 23:39
Marc

Thanks for getting back to me so quickly on this.  I'm running an apple
version of python from the looks of it.  I was running an Anaconda version
at the time I posted this script, but I just reset my $PATH variable to use
the mac factory python and still got the error.

Python 2.7.5 (default, Sep 12 2013, 21:33:34)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

On Wed, Dec 18, 2013 at 5:17 PM, Marc-Andre Lemburg
<report@bugs.python.org>wrote:

>
> Marc-Andre Lemburg added the comment:
>
> I have tried this with a stock Python 2.7.6 version and don't get an error:
>
> >>> platform._sys_version('2.7.5 (default, Sep 12 2013, 21:33:34) \n[GCC
> 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]')
> ('CPython', '2.7.5', '', '', 'default', 'Sep 12 2013 21:33:34', 'GCC 4.2.1
> Compatible Apple LLVM 5.0 (clang-500.0.68)')
>
> The stackoverflow posting you mentioned obviously uses a Python version
> that was modified in incompatible ways, so it doesn't apply here.
>
> Are you running an Apple version of Python or one that was installed using
> the python.org installer ?
>
> ----------
> components: +Library (Lib) -2to3 (2.x to 3.x conversion tool)
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue20019>
> _______________________________________
>
msg206563 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2013-12-18 23:46
On 19.12.2013 00:39, Wes wrote:
> 
> Marc
> 
> Thanks for getting back to me so quickly on this.  I'm running an apple
> version of python from the looks of it.  I was running an Anaconda version
> at the time I posted this script, but I just reset my $PATH variable to use
> the mac factory python and still got the error.
> 
> Python 2.7.5 (default, Sep 12 2013, 21:33:34)
> [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.

That looks pretty much the same.

I suspect that either Apple changed something in their Python
version or that pip is picking up a non-standard platform.py
from somewhere.

Could you check platform.__file__ and sys.version ?
msg206564 - (view) Author: Wes (wesmadrigal) Date: 2013-12-18 23:52
Marc,

Here was the initial output:

>>> platform.__file__
'/Users/wesmadrigal/anaconda/lib/python2.7/platform.pyc'
>>> import sys
>>> sys.version
'2.7.6 |Anaconda 1.8.0 (x86_64)| (default, Nov 11 2013, 10:49:09) \n[GCC
4.0.1 (Apple Inc. build 5493)]'

Here is what I had when I reverted back to the standard $PATH that comes
stock in Mac OSX Mountain Lion on this new Macbook Pro:

>>> platform.__file__
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/platform.pyc'
>>> import sys
>>> sys.version
'2.7.5 (default, Sep 12 2013, 21:33:34) \n[GCC 4.2.1 Compatible Apple LLVM
5.0 (clang-500.0.68)]'

On Wed, Dec 18, 2013 at 5:46 PM, Marc-Andre Lemburg
<report@bugs.python.org>wrote:

>
> Marc-Andre Lemburg added the comment:
>
> On 19.12.2013 00:39, Wes wrote:
> >
> > Marc
> >
> > Thanks for getting back to me so quickly on this.  I'm running an apple
> > version of python from the looks of it.  I was running an Anaconda
> version
> > at the time I posted this script, but I just reset my $PATH variable to
> use
> > the mac factory python and still got the error.
> >
> > Python 2.7.5 (default, Sep 12 2013, 21:33:34)
> > [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
> > Type "help", "copyright", "credits" or "license" for more information.
>
> That looks pretty much the same.
>
> I suspect that either Apple changed something in their Python
> version or that pip is picking up a non-standard platform.py
> from somewhere.
>
> Could you check platform.__file__ and sys.version ?
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue20019>
> _______________________________________
>
msg206565 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-12-18 23:53
The version string does not match either the Apple-supplied Python in 10.8 (Mountain Lion) nor that of a python.org Python.  The "anaconda" directory name suggests this is probably a Python from the Anaconda Scientific distribution.  There have been other issues with _sys_version as reported on their bug tracker; see https://github.com/ContinuumIO/anaconda-issues/search?q=_sys_version&type=Issues
msg206566 - (view) Author: Wes (wesmadrigal) Date: 2013-12-19 00:08
I just commented out the _sys_version_parser regular expression in
anaconda/lib/python2.7/platform.py on line 1363 and replaced it with the
_sys_version_parser from /usr/lib/python2.7/platform.py and everything
worked fine.

On Wed, Dec 18, 2013 at 5:53 PM, Ned Deily <report@bugs.python.org> wrote:

>
> Ned Deily added the comment:
>
> The version string does not match either the Apple-supplied Python in 10.8
> (Mountain Lion) nor that of a python.org Python.  The "anaconda"
> directory name suggests this is probably a Python from the Anaconda
> Scientific distribution.  There have been other issues with _sys_version as
> reported on their bug tracker; see
> https://github.com/ContinuumIO/anaconda-issues/search?q=_sys_version&type=Issues
>
> ----------
> nosy: +ned.deily
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue20019>
> _______________________________________
>
msg206567 - (view) Author: Wes (wesmadrigal) Date: 2013-12-19 00:08
The shitty part is, you pretty much need anaconda to run iPython notebook
on a mac.

On Wed, Dec 18, 2013 at 6:08 PM, Wes Madrigal <wesley7879@gmail.com> wrote:

> I just commented out the _sys_version_parser regular expression in
> anaconda/lib/python2.7/platform.py on line 1363 and replaced it with the
> _sys_version_parser from /usr/lib/python2.7/platform.py and everything
> worked fine.
>
>
> On Wed, Dec 18, 2013 at 5:53 PM, Ned Deily <report@bugs.python.org> wrote:
>
>>
>> Ned Deily added the comment:
>>
>> The version string does not match either the Apple-supplied Python in
>> 10.8 (Mountain Lion) nor that of a python.org Python.  The "anaconda"
>> directory name suggests this is probably a Python from the Anaconda
>> Scientific distribution.  There have been other issues with _sys_version as
>> reported on their bug tracker; see
>> https://github.com/ContinuumIO/anaconda-issues/search?q=_sys_version&type=Issues
>>
>> ----------
>> nosy: +ned.deily
>>
>> _______________________________________
>> Python tracker <report@bugs.python.org>
>> <http://bugs.python.org/issue20019>
>> _______________________________________
>>
>
>
msg206568 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2013-12-19 00:14
On 19.12.2013 00:52, Wes wrote:
> 
> Marc,
> 
> Here was the initial output:
> 
>>>> platform.__file__
> '/Users/wesmadrigal/anaconda/lib/python2.7/platform.pyc'
>>>> import sys
>>>> sys.version
> '2.7.6 |Anaconda 1.8.0 (x86_64)| (default, Nov 11 2013, 10:49:09) \n[GCC
> 4.0.1 (Apple Inc. build 5493)]'

The part '|Anaconda 1.8.0 (x86_64)|' in that string is not standard
Python conform and as a result, the platform.py parser fails.

You'll have to open a ticket with the Anaconda vendor to get this
fixed.

> Here is what I had when I reverted back to the standard $PATH that comes
> stock in Mac OSX Mountain Lion on this new Macbook Pro:
> 
>>>> platform.__file__
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/platform.pyc'
>>>> import sys
>>>> sys.version
> '2.7.5 (default, Sep 12 2013, 21:33:34) \n[GCC 4.2.1 Compatible Apple LLVM
> 5.0 (clang-500.0.68)]'

This should parse correctly with the stock platform.py parser.

The only explanation I have is that the platform.py installed
on your machine is not the original one that comes with the
Python 2.7.5 we distribute from python.org.

I don't have a Mac OSX notebook available to check, so can't
really help.
msg206569 - (view) Author: Wes (wesmadrigal) Date: 2013-12-19 00:20
Marc,

Thanks for your help.

What I did was just copied the _sys_version_parser from the standard python
platform.py into the anaconda version of platform.py and it fixed the
issue.  So it looks like Anaconda made a change to your regular expression.

Thanks for getting on the issue so quick and staying with it, though.

On Wed, Dec 18, 2013 at 6:14 PM, Marc-Andre Lemburg
<report@bugs.python.org>wrote:

>
> Marc-Andre Lemburg added the comment:
>
> On 19.12.2013 00:52, Wes wrote:
> >
> > Marc,
> >
> > Here was the initial output:
> >
> >>>> platform.__file__
> > '/Users/wesmadrigal/anaconda/lib/python2.7/platform.pyc'
> >>>> import sys
> >>>> sys.version
> > '2.7.6 |Anaconda 1.8.0 (x86_64)| (default, Nov 11 2013, 10:49:09) \n[GCC
> > 4.0.1 (Apple Inc. build 5493)]'
>
> The part '|Anaconda 1.8.0 (x86_64)|' in that string is not standard
> Python conform and as a result, the platform.py parser fails.
>
> You'll have to open a ticket with the Anaconda vendor to get this
> fixed.
>
> > Here is what I had when I reverted back to the standard $PATH that comes
> > stock in Mac OSX Mountain Lion on this new Macbook Pro:
> >
> >>>> platform.__file__
> >
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/platform.pyc'
> >>>> import sys
> >>>> sys.version
> > '2.7.5 (default, Sep 12 2013, 21:33:34) \n[GCC 4.2.1 Compatible Apple
> LLVM
> > 5.0 (clang-500.0.68)]'
>
> This should parse correctly with the stock platform.py parser.
>
> The only explanation I have is that the platform.py installed
> on your machine is not the original one that comes with the
> Python 2.7.5 we distribute from python.org.
>
> I don't have a Mac OSX notebook available to check, so can't
> really help.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue20019>
> _______________________________________
>
msg206590 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2013-12-19 09:06
Closing, since there's nothing much we can do about the problem.
msg206618 - (view) Author: Wes (wesmadrigal) Date: 2013-12-19 15:22
I'll submit this to Continuum Analytics so they know it's their issue.

On Thu, Dec 19, 2013 at 3:06 AM, Marc-Andre Lemburg
<report@bugs.python.org>wrote:

>
> Marc-Andre Lemburg added the comment:
>
> Closing, since there's nothing much we can do about the problem.
>
> ----------
> resolution:  -> invalid
> status: open -> closed
> versions: +3rd party -Python 2.7
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue20019>
> _______________________________________
>
History
Date User Action Args
2022-04-11 14:57:55adminsetgithub: 64218
2013-12-19 15:22:09wesmadrigalsetmessages: + msg206618
2013-12-19 09:06:27lemburgsetstatus: open -> closed
resolution: not a bug
messages: + msg206590

versions: + 3rd party, - Python 2.7
2013-12-19 00:20:57wesmadrigalsetmessages: + msg206569
2013-12-19 00:14:06lemburgsetmessages: + msg206568
2013-12-19 00:08:52wesmadrigalsetmessages: + msg206567
2013-12-19 00:08:12wesmadrigalsetmessages: + msg206566
2013-12-18 23:53:47ned.deilysetnosy: + ned.deily
messages: + msg206565
2013-12-18 23:52:16wesmadrigalsetmessages: + msg206564
2013-12-18 23:46:43lemburgsetmessages: + msg206563
2013-12-18 23:39:45wesmadrigalsetmessages: + msg206562
2013-12-18 23:17:13lemburgsetmessages: + msg206561
components: + Library (Lib), - 2to3 (2.x to 3.x conversion tool)
2013-12-18 23:08:47wesmadrigalcreate