我之前问过类似的问题,但我终于解决了它,但现在我卡住了。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'
缩进修正不在这里。