Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac app - Sometimes it's not possible to get the user env vars #1359

Closed
spyder-bot opened this issue Feb 17, 2015 · 15 comments
Closed

Mac app - Sometimes it's not possible to get the user env vars #1359

spyder-bot opened this issue Feb 17, 2015 · 15 comments

Comments

@spyder-bot
Copy link
Collaborator

From pierre.g...@gmail.com on 2013-04-19T18:12:04Z

Hi,

I can't get 'spyder-2.2.0rc_Lion.dmg' to install Spyder on my laptop running OS X 10.8.3.
(and that one last version doesn't seem to be available using macports)

  • Launching for the first time (after copying app to folder Applications) the icon from /Applications will just produce a 'Spyder Error' message
  • Launching '/Applications/Spyder.app/Contents/MacOS/Spyder' script will produce the following output :

Traceback (most recent call last):
File "/Applications/Spyder.app/Contents/Resources/boot.py", line 19, in
_get_env()
File "/Applications/Spyder.app/Contents/Resources/boot.py", line 18, in _get_env
os.environ.update(env)
File "os.pyc", line 479, in update
ValueError: need more than 1 value to unpack
2013-04-20 00:37:40.149 Spyder[39872:707] Spyder Error
Terminated: 15
logout

Am I missing something obvious?

thank you,
pierre

PS : I have started to use Spyder a month ago, thank you for the amazing work!!

Original issue: http://code.google.com/p/spyderlib/issues/detail?id=1359

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-04-23T14:31:06Z

Sorry about the hassle. I introduced the _get_env function to load environment variables in the current Spyder session. The error message you saw probably means that you have none :)

I already have a fix for this and will merge it before the final release.

Labels: -Priority-Medium Priority-Critical MS-v2.2 OpSys-OSX

@spyder-bot
Copy link
Collaborator Author

From pierre.g...@gmail.com on 2013-04-23T15:25:23Z

Thank you for your answer!

I'm very much of an amateur on these topics so please excuse all the idiotic things that i will probably say. Just as a follow-up, i tried to understand what were these environment variables and if i had none as you said :)

to the command

import os
print os.environ

i get a consistent list of keys and values (including 'PATH', 'HOME', 'PYTHONPATH', etc.)

if i comment out the following code in 'boot.py' :

def _get_env():

import os

import subprocess as sp

if os.path.isfile(os.getenv('HOME') + os.path.sep + '.profile'):

envstr = sp.check_output('source /etc/profile; source ~/.profile; printenv',

shell=True)

else:

envstr = sp.check_output('source /etc/profile; printenv', shell=True)

env = [a.split('=') for a in envstr.strip().split('\n')]

os.environ.update(env)

_get_env()

then Spyder.app launches! it seems that there nothing tragic in doing that, right?, and that it could do it for me before the final release. tell me if i'm going to hell this very minute :)

merci encore!!
pierre

@spyder-bot
Copy link
Collaborator Author

From maquit...@gmail.com on 2013-04-26T11:53:35Z

I had the same problem, with Mac OS X 10.7.8. The "solution" was to put all the function _get_env() between """ """

And now it works

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-04-27T07:56:24Z

Guys, please help to debug this: put a print statement after the line

env = [a.split('=') for a in envstr.strip().split('\n')]

such as

print env

uncomment _get_env() and put the print contents here (which should be available in Console.app) to let me know why it's throwing an error.

I thought the error was generated because there weren't env variables defined in some systems, but Pierre's comment #2 seems to indicate that that's not the case.

Summary: Mac app - Can't start Spyder-2.2.0rc because of error while getting environment vars (was: Mac app - Can't install spyder-2.2.0rc_Lion.dmg on OS X 10.8.3)

@spyder-bot
Copy link
Collaborator Author

From jed.lud...@gmail.com on 2013-04-29T15:08:37Z

Labels: MS-v2.2.1

@spyder-bot
Copy link
Collaborator Author

From jed.lud...@gmail.com on 2013-04-29T15:10:06Z

Labels: -MS-v2.2

@spyder-bot
Copy link
Collaborator Author

From bor...@gmail.com on 2013-05-11T15:17:57Z

I also had this issue and commenting that line fixes the issue (I used the .DMG version).

Carlos, I printed the env variable just before the crash, and the problem seems to be that some sublists are emtpy:

['PIP_DOWNLOAD_CACHE', '/Users/boriel/.pip/cache']
['TERM_PROGRAM', 'Apple_Terminal']
['PIP_REQUIRE_VIRTUALENV', 'true']
['TERM', 'xterm-256color']
['SHELL', '/bin/bash']
...
[''] <= HERE
['PAGER', 'less']
['EDITOR', 'vim']
['LANG', 'es_ES.UTF-8']
['PYTHONHOME', '/Applications/Spyder.app/Contents/Resources']
['PS1', '[\033[01;32m]\u@\h[\033[00m]:[\033[01;34m]\w[\033[00m]$ ']
...
['_', '/usr/bin/printenv']

Printing envstr shows a blank line, so a fix could be defining env as:
env = [a.split('=') for a in envstr.strip().split('\n') if a]

This works, but I don't know if this is what you intented.
:)

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-05-14T14:44:38Z

I uploaded a new version that has a partial fix for this problem: at least it doesn't crash if it can't get the user env vars.

Thanks boriel for your suggestion. I'll try to incorporate it for 2.2.1 after I analyze more deeply what's really happening.

@spyder-bot
Copy link
Collaborator Author

From bor...@gmail.com on 2013-05-14T14:53:43Z

This fix works!! Thanks, Carlos! :)

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-06-19T18:45:20Z

I'll need more time to investigate this, so I'm leaving it for 2.3

Labels: -MS-v2.2.1 MS-v2.3

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-06-29T14:43:35Z

Summary: Mac app - Sometimes it's not possible to get the user env vars (was: Mac app - Can't start Spyder-2.2.0rc because of error while getting environment vars)

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-12-11T12:41:23Z

Labels: -MS-v2.3 MS-v2.3.1

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-12-30T15:58:25Z

issue #1383 has been merged into this issue.

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2014-08-17T18:52:50Z

Labels: -MS-v2.3.1 MS-v2.3.2

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2014-10-26T10:20:59Z

Labels: -Priority-Critical -MS-v2.3.2 Priority-High MS-v2.4

@ccordoba12 ccordoba12 modified the milestones: v2.3.4, v2.4 Mar 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants