{"action":"created","issue":{"url":"https://api.github.com/repos/extrabacon/python-shell/issues/111","repository_url":"https://api.github.com/repos/extrabacon/python-shell","labels_url":"https://api.github.com/repos/extrabacon/python-shell/issues/111/labels{/name}","comments_url":"https://api.github.com/repos/extrabacon/python-shell/issues/111/comments","events_url":"https://api.github.com/repos/extrabacon/python-shell/issues/111/events","html_url":"https://github.com/extrabacon/python-shell/issues/111","id":301967991,"number":111,"title":"option to specify python version","user":{"login":"Almenon","id":13080965,"avatar_url":"https://avatars0.githubusercontent.com/u/13080965?v=4","gravatar_id":"","url":"https://api.github.com/users/Almenon","html_url":"https://github.com/Almenon","followers_url":"https://api.github.com/users/Almenon/followers","following_url":"https://api.github.com/users/Almenon/following{/other_user}","gists_url":"https://api.github.com/users/Almenon/gists{/gist_id}","starred_url":"https://api.github.com/users/Almenon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Almenon/subscriptions","organizations_url":"https://api.github.com/users/Almenon/orgs","repos_url":"https://api.github.com/users/Almenon/repos","events_url":"https://api.github.com/users/Almenon/events{/privacy}","received_events_url":"https://api.github.com/users/Almenon/received_events","type":"User","site_admin":false},"labels":[{"id":85607090,"url":"https://api.github.com/repos/extrabacon/python-shell/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-03T04:36:26Z","updated_at":"2018-03-21T16:30:35Z","closed_at":null,"author_association":"COLLABORATOR","body":"In arepl-backend I have code that invokes \"python3\" instead of \"python\" if on a mac.\r\n\r\n(non-windows OS ships with python 2 so python 3 needs to be specified)\r\n\r\nIt would be nice if this functionality was baked into python-shell:\r\n\r\n```javascript\r\nvar PythonShell = require('python-shell');\r\n\r\nvar options = {\r\n  version: '3',\r\n};\r\n\r\nvar pyshell = new PythonShell('my_script.py', options);\r\n// PythonShell uses python3 on mac, otherwise python 2\r\n\r\nvar options = {\r\n  version: '3.5',\r\n};\r\n\r\npyshell = new PythonShell('my_script.py', options);\r\n// in addition to above logic PythonShell checks the version and throws an error if wrong version\r\n\r\nvar options = {\r\n  version: '^3.5',\r\n};\r\n\r\npyshell = new PythonShell('my_script.py', options);\r\n// versioning should use [SEMVER](http://nodesource.com/blog/semver-tilde-and-caret/)\r\n// aka 3.5 and up is allowed\r\n\r\nvar options = {\r\n  version: '^3.5',\r\n  pythonPath: 'python'\r\n};\r\n\r\npyshell = new PythonShell('my_script.py', options);\r\n// pythonPath has final decision, so even if on mac \"python\" will be used instead of python3\r\n```\r\n\r\nI might work on this if I have time."},"comment":{"url":"https://api.github.com/repos/extrabacon/python-shell/issues/comments/375006816","html_url":"https://github.com/extrabacon/python-shell/issues/111#issuecomment-375006816","issue_url":"https://api.github.com/repos/extrabacon/python-shell/issues/111","id":375006816,"user":{"login":"Drulac","id":17110977,"avatar_url":"https://avatars2.githubusercontent.com/u/17110977?v=4","gravatar_id":"","url":"https://api.github.com/users/Drulac","html_url":"https://github.com/Drulac","followers_url":"https://api.github.com/users/Drulac/followers","following_url":"https://api.github.com/users/Drulac/following{/other_user}","gists_url":"https://api.github.com/users/Drulac/gists{/gist_id}","starred_url":"https://api.github.com/users/Drulac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Drulac/subscriptions","organizations_url":"https://api.github.com/users/Drulac/orgs","repos_url":"https://api.github.com/users/Drulac/repos","events_url":"https://api.github.com/users/Drulac/events{/privacy}","received_events_url":"https://api.github.com/users/Drulac/received_events","type":"User","site_admin":false},"created_at":"2018-03-21T16:30:35Z","updated_at":"2018-03-21T16:30:35Z","author_association":"NONE","body":"You can do it just by precising python3 as python path : \r\n```js\r\nvar PythonShell = require('python-shell');\r\n\r\nvar options = { pythonPath: 'python3' };\r\n\r\nPythonShell.run('my_script.py', options, function (err, results) {\r\n\r\n});\r\n```"}}
{"actor":{"display_login":"Drulac"}}