title: OSError: [Errno 22] Python PHP Problem
body: <p>I asked a similar question prior but i finally got further along in solving it, but now i am stuck.</p>
  
  <p>I am running python on a webserver on dreamhost.  I shell into it using putty and run my python script and it works great.  But when i run it from php using exec, it crashes.</p>
  
  <p>Using the passthru() function in php i get returned with this error:</p>
  
  <pre><code>Traceback (most recent call last): File "newwork.py", line 20, 
  in api=lastfm.Api(api_key) File "lastfm/api.py", line 22, 
  in __init__ File "lastfm/filecache.py", line 19, 
  in __init__ File "lastfm/filecache.py", line 76, 
  in _InitializeRootDirectory File "lastfm/filecache.py", line 70, 
  in _GetTmpCachePath File "lastfm/filecache.py", line 66, 
  in _GetUsername OSError: [Errno 22] Invalid argument 
  </code></pre>
  
  <p>i have no clue what that means or where i should start.   for more info i am using the python lastfm module found here: <a href="http://code.google.com/p/python-lastfm/" rel="nofollow">http://code.google.com/p/python-lastfm/</a></p>
  
  <p>and my python script simply does this:</p>
  
  <pre><code>import sys
  import lastfm
  import MySQLdb
  
  sys.stderr=sys.stdout
  value="testuser"
  api_key='---my api key is here'
  api=lastfm.Api(api_key)
  user=api.getUser(value)
  top_artists=user.topArtists
  </code></pre>
  
  <p>any help would be greatly appreciated, or any ideas whatsoever.  I dont even know where to start.</p>
  
  <p>Edit:  i did a little more work and found the full last line is:</p>
  
  <pre><code>line 66, in _GetUsername os.getlogin() or \ OSError: [Errno 22] Invalid argument 
  </code></pre>
  
  <p>and the GetUsername function simply is this:</p>
  
  <pre><code>def _GetUsername(self):
  '''Attempt to find the username in a cross-platform fashion.'''
  return os.getenv('USER') or \
  os.getenv('LOGNAME') or \
  os.getenv('USERNAME') or \
  os.getlogin() or \
  'nobody'
  </code></pre>
  
  <p>with indentation corrected not here.</p>