Home Download Buy Blog Forum Support

My build accesses Python 3.3 same path as Ipython.. or NOT

My build accesses Python 3.3 same path as Ipython.. or NOT

Postby regikeyz on Tue Feb 25, 2014 1:19 pm

hi guys,

Ok, I want to run this Python code:

import json
import requests
import sys

print (sys.version)

for each in sys.path:
print (each)

requests.get('http://www.google.co.uk')


I can run it fine in Ipython, but when I run in Sublime text 2.0.2, I get an error with the 'requests.get(..' code:
Here is output:

3.3.2+ (default, Oct 9 2013, 14:50:09)
[GCC 4.8.1]
/home/dataist/ml/udacityDA/lesson2
/home/dataist/miniconda3/bin
/home/dataist/miniconda3/lib/python3.3
/home/dataist/miniconda3/lib/python3.3/plat-linux
/home/dataist/miniconda3/lib/python3.3/lib-dynload
/home/dataist/miniconda3/lib/python3.3/site-packages
/home/dataist/miniconda3/lib/python3.3/site-packages/setuptools-2.1-py3.3.egg
/home/dataist/miniconda3/lib/python3.3/site-packages/IPython/extensions
/usr/lib/python3.3
/usr/lib/python3.3/plat-x86_64-linux-gnu
/usr/lib/python3.3/lib-dynload
Traceback (most recent call last):
File "/home/dataist/ml/udacityDA/lesson2/lastfm_api_code.py", line 18, in <module>
requests.get('http://www.google.co.uk')
File "/home/dataist/miniconda3/lib/python3.3/site-packages/requests/api.py", line 55, in get
return request('get', url, **kwargs)
File "/home/dataist/miniconda3/lib/python3.3/site-packages/requests/api.py", line 43, in request
session = sessions.Session()
File "/home/dataist/miniconda3/lib/python3.3/site-packages/requests/sessions.py", line 200, in __init__
self.headers = default_headers()
File "/home/dataist/miniconda3/lib/python3.3/site-packages/requests/utils.py", line 550, in default_headers
'User-Agent': default_user_agent(),
File "/home/dataist/miniconda3/lib/python3.3/site-packages/requests/utils.py", line 519, in default_user_agent
_implementation = platform.python_implementation()
File "/home/dataist/miniconda3/lib/python3.3/platform.py", line 1383, in python_implementation
return _sys_version()[0]
File "/home/dataist/miniconda3/lib/python3.3/platform.py", line 1346, in _sys_version
repr(sys_version))
ValueError: failed to parse CPython sys.version: '3.3.2+ (default, Oct 9 2013, 14:50:09) \n[GCC 4.8.1]'
[Finished in 0.1s with exit code 1]


Now, I made my build to be this:
{
"cmd": ["python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"env":
{
"PYTHONPATH":"/home/dataist/miniconda3/bin/:/home/dataist/miniconda3/lib/python3.3:/home/dataist/miniconda3/lib/python3.3/plat-linux:/home/dataist/miniconda3/lib/python3.3/lib-dynload:/home/dataist/miniconda3/lib/python3.3/site-packages:/home/dataist/miniconda3/lib/python3.3/site-packages/setuptools-2.1-py3.3.egg:/home/dataist/miniconda3/lib/python3.3/site-packages/IPython/extensions"
}
}


But this code works fine on Ipython..
However Ipython seems to be using 3.3.4, and Sublime seems to be using 3.3.2 EVEN THO I USED THE SAME PYTHON INSTALLATION?
(or did I ?!)

In Ipython when I run:
print (sys.version)
I get:
3.3.4 |Continuum Analytics, Inc.| (default, Feb 10 2014, 17:53:28)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)]


this is different than running same command in sublime..

But when I list the path in ipython, I get this:
for each in sys.path:
....: print (each)

/home/dataist/miniconda3/bin
/home/dataist/miniconda3/lib/python33.zip
/home/dataist/miniconda3/lib/python3.3
/home/dataist/miniconda3/lib/python3.3/plat-linux
/home/dataist/miniconda3/lib/python3.3/lib-dynload
/home/dataist/miniconda3/lib/python3.3/site-packages
/home/dataist/miniconda3/lib/python3.3/site-packages/setuptools-2.1-py3.3.egg
/home/dataist/miniconda3/lib/python3.3/site-packages/IPython/extensions


If you notice, it is almost the same as Sublime output, but Sublime has added extra stuff to the path..

Why does sublime use 3.3.2+ (default, Oct 9 2013, 14:50:09) as default when I specifically point it towards 3.3.4 ?
I'm pretty new to this and obviously something I'm not quite understanding.
I've lost a day trying to get Sublime to use Python 3.3, if anyone can shed some light on this, you don't know how grateful I would be!

Thank-you so much for reading
Kind Regards
regikeyz
 
Posts: 1
Joined: Tue Feb 25, 2014 1:01 pm

Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 16 guests