我之前問過類似的問題,但我終於解決了它,但現在我卡住了。OSError:[Errno 22] Python PHP問題
我在Dreamhost上的web服務器上運行python。我使用putty將其殼化,然後運行我的python腳本,效果很好。但是當我使用exec從php運行它時,它崩潰了。
使用PHP時得到與此錯誤返回的中繼()函數:
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
我不知道這意味着什麼或者我應該開始。更多信息我使用這裏找到蟒蛇LastFM等模塊:http://code.google.com/p/python-lastfm/
和我的Python腳本簡單地做到這一點:
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
任何幫助,將不勝感激,或不得以任何想法。我甚至不知道從哪裏開始。
編輯:我做了一些更多的工作,發現全最後一行是:
line 66, in _GetUsername os.getlogin() or \ OSError: [Errno 22] Invalid argument
和GetUsername功能簡單說就是:
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'
縮進修正不在這裏。