How to change directoy or Python downloads - python-2.7

I have this script to download images. But the problem is it saves the files in the same directory with the script. How can i change to to save in another directory? Id love for it to be here G:\Downloads\PICTURES
Here is the script http://pastebin.com/raw.php?i=2PnuMNnW
I didnt make this, so thanks to the person who wrote it.

As can be found in the Python Docs:
import os
os.chdir(/path/to/directory)
Change the current working directory to path.

Related

Install third-party Markdown extension in Pelican

I'm using Pelican for a static blog, and attempting to install the figure-ref extension. Since I'm using Markdown, the plugin relies on the figureAltCaption third-party Markdown extension. However I have no idea how to install it.
Pelican has an MD_EXTENSIONS configuration option, but I've tried a few obvious options with no luck. It seems like this is a dead-simple gimme but it's not clear how to proceed. Would love some suggestions.
Unfortunately, the author of figureAltCaption appears to have not provided an install script. My suggestion would be to create one and contribute it as a pull request. This tutorial about creating Extensions for Python-Markdown covers creating an install script as well.
However, as a shortcut, you should be able to just copy the figureAltCaption.py file to the appropriate directory. Usually you want the site-packages directory. As this answer shows, just do the following from Python:
>>> import site; site.getsitepackages()
Then copy the figureAltCaption.py file to the first directory returned.
Now that the extension is on your PYTHONPATH, it should be importable. From the Python prompt, try:
import figureAltCaption
If you get no errors, then it worked and you just need to tell Pelican about it.
MD_EXTENSIONS = ['figureAltCaption']

use to import dta doesn't work for the file in folder?

I just did
use "data.dta"
My do file and dta are in the same folder. But it shows me error.
I also tried
use "datafolder/data.dta"
after placing data.dta into that folder. But this doesn't work either.
What should I write? It is not a good idea to write like
use "D://... /... /data.dta"
because other people should be able to run this code on his computer.
Before read the dta file, we need to tell Stata the current directory. Usually we can use cd command to change the current working directory. For example, if the data.dta is under the "C:\temp" folder, then use the following code:
cd "C:\temp"
use "data.dta"

how can i properly copy this file to another directory in Ubuntu 14.0

cp -i /usr/local/lib/python2.7/dist-packages/django/template/admin/base_site.html /usr/local/lib/python2.7/dist-packages/django/template/admin
I am trying to 'CUSTOMIZE MY PROJECT TEMPLATE' from the Django 1.8 POLLS tutorial
https://docs.djangoproject.com/en/1.8/intro/tutorial02/
but no avail, i am having a hard time trying to copy the "base_site.html" file to the "django/contrib/admin/templates"
help me learn!
You may misunderstand the tutorial, It said: copy it from the default directory into your custom directory, and make changes, it seems that you command above is trying to duplicate the file.
first, find your Django source file location:
python -c "
import sys
sys.path = sys.path[1:]
import django
print(django.__path__)"
you will get a link, go deep into the folder, find that template, then copy the base_site.html to your project's template folder.

django runserver error from SVN co

I have written a Django project which runs fine on the dev server. Although I am the only one working on it, I realized I should get some sort of version control going and placed the project on a network SVN. I assume the new process for working this project should be: checkout code from SVN, make changes, test, update, and commit back to SVN.
However, when I check out the code and attempt to run the dev server from the checked out SVN location, I get an error that "has no module named yadda.yadda". But, the module is there and it works fine when I run it from the original directory. Any thoughts? Any suggestions on a better work process?
Does your $PYTHONPATH shell variable reference a relative path? If so, the relative path may be incorrect when you change to the new directory.
You can also diff the contents of the two directories to ensure that your versioned copy is a duplicate of the original.
Check if your module has init.py
As George said check if module is on python path (import sys and print sys.path)

Django start new project error

i have installed Python2.6 and Django1.2.4 on windows vista. or so i think django is installed.
i test it this by opening the python shell(command prompt from the python folder) and typed this:
import django
django.get_version()
The result was "1.2.4". From this i understand that firstly python works, and second that django is installed, recognized.
Following the tutorial from Django website i get stuck on the first thing: creating a project
django-admin.py startproject mysite
I wrote this in a new command prompt window, chdir my way to a folder i decided it'll keep the project and then wrote the line above. The error is this:
E:\Workspace>django-admin.py startproject mysite
'django-admin.py' is not recognized as an internal or external command,
operable program or batch file.
I tried with writting "python" before the line but no.
I added in the Environmental Variables , in the PATH, the path to the bin folder of django and the path to python. I have the django-admin.py file in the Python/Scripts folder.
I understand this is a very easy , newbie mistake, but it currently blocks me. If somebody has gone through this error or knows about it, a bit of help would be much appreciated.
Thank you either way!
Did you to add the Python/Scripts to the PATH environmental variable? You'll need to restart any command prompts you have opened for the PATH change to take effect.
The same happened with me also and it is resolved by adding PATH environmental variable of Python\scripts.