I have to run a few python scripts and was trying to create a bash script to do it for me. The bash script is as follows:
#!/bin/bash
FILE=$(ls | grep .\.py)
for f in $FILE
do
python2.6 $f
done
And the following error pops up for each of python calls:
SyntaxError: invalid syntax
Traceback (most recent call last):
File "script.py", line 2, in ?
import requests
File "/[some path]/python/local/lib/python2.6/site-packages/requests-2.0.0-py2.6.egg/requests/__init__.py", line 53
from .packages.urllib3.contrib import pyopenssl
Any ideas would help a lot. Thanks for your time.
EDIT:
Output from
import sys
print sys.version
...
2.6.6 (r266:84292, Nov 21 2013, 10:50:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
Can you go into the interpreter and do import requests
and it works?
Can you test which version of python you are calling by doing an import sys
, print sys.version
before the import requests
? Also possibly check your pythonpath variables to make sure you aren't improperly mixing different versions of python.
Also, you seem to be using a rather old version of requests. It may make sense to upgrade to a newer version (or at least check through the issues to see if anyone else has encountered this).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.