I originally asked this question and took up Martijn Pieters solution and did as he posted:
However, I'm still unable to run my file out of Terminal. I should see files being saved in to the folder thisdir
.
I've changed my directory to the directory of the file and I run
./my_file.py --todir thisdir foobar
But I'm still getting
Traceback (most recent call last):
File "my_file.py", line 13, in <module>
import requests
ImportError: No module named requests
I don't know if it matters, but I've tried running it with the first line of my file containing
#!/usr/bin/env python
as well as
#!/usr/bin/python
I really have no idea what I'm doing here, could someone please help me through this?
Update:
I replaced the shebang in my code, and I no longer get an error, but I also don't get any output (the issue isn't a bug in the code as I tested it fully). Here's the part of my code that requires requests
The part of my code that uses requests is below. I don't know if it
for i in xrange(urls_count):
r = requests.get(urls[i], stream=True)
with open(save_here + '/file' + str(i), 'wb') as f_in:
f_in.write(r.content)
I should see files being saved into thisdir
and also in Terminal, a list of the newly created file's names being print out (in Terminal). So the issue isn't to add print the content (as suggested by hd1).
Also, not sure if this is relevant, but I clicked the box for "Install to user's site packages directory (/Users/AlanH/.local)