2007-03-16

EN | Console on Windows without Admin rights

I am working in the corporate environment. And based on the fact that I am not in the corporation structure set in the boxes of developers, I have quite limited access to the functionality of my Windows notebook even though I work in IT. Highly limited access. I cannot even run commands from the command line. To be fair, though, this is quite common practice, which saves time to my fellow IT colleagues when something gets broken. On the other hand it highly limits me, when some tasks can be done quickly using commands from the command line.

How is this related to Django?

Believe me or not, it is much faster (read less stressful) for me to setup a small running intra-web application in 2 hours than asking several committees to approve the project to actually build the same. So I love Django and Python for these quick, dirty, and as I stress to everyone, temporary solutions. And believe me, as I am from IT department, when I say temporary, it really gets wiped out at the set date.

When managing Django one needs to run commands from the command line quite often. Therefore having command line access is pretty useful.

So the mission was: set the USB portable command line tools for a Django development, where no Admin rights and no installation is needed.

This is the shopping list:

[] Portable Python
[] Pyreadline
[] IPython
[] Console2

For the Portable Python - download the .zip file from http://www.portablepython.com/site/download/

It is currently in Beta 1.0 having Python 2.5 with some other stuff already added.

We will work in the root of separate drive (L:), but you should be able to set everything anywhere.

We put all development tools into the directory \devtools\


Unzip the PortablePython1.0.zip into the devtools and rename the final dir PortablePython1.0 to python.

Test the python "installation" by running python (not the pythonw). You should get something like this:


Shopping list so far:

[x] Portable Python
[] Pyreadline
[] IPython
[] Console2

IPython is little bit trickier. For the tab completion, coloring and some other nice stuff it needs pyreadline when running on Windows. Just download the .exe installer from http://ipython.scipy.org/dist/pyreadline-1.3.win32.exe

If you do not want to populate registry, unzip the installer .exe and copy the content of the PURELIB directory into L:\devtools\python\Lib\site-packages



You can test the "installation" by running python and executing
> import pyreadline
It should not give you any error.

Shopping list so far:

[x] Portable Python
[x] Pyreadline
[] IPython
[] Console2

Now IPython can be downloaded from http://ipython.scipy.org/dist/ipython-0.7.2.win32.exe and again just unzip the .exe into some temporary folder. From there I just copied the content of PURELIB into into L:\devtools\python\Lib\site-packages and whole folder SCRIPTS moved into L:\devtools\python





You can test the "installation" by running python and executing
import IPython
IPython.Shell.start().mainloop()



Shopping list so far:

[x] Portable Python
[x] Pyreadline
[x] IPython
[] Console2

Basically it is possible to run commands since the IPython is installed, but I wanted to have nice Terminal window. This can be downloaded from http://sourceforge.net/projects/console/
I took the latest Console-2.00b129-Beta.zip and unziped into the content into L:\devtools


Now when you run the Console and have some corporate restrictions you get similar error to the following one


Put following configuration into the Settings / Console / Shell
\devtools\python\python.exe \devtools\python\SCRIPTS\ipython
and some high number (eg. 800) to the Settings / Console / Buffer size / Rows in order to get scrollable window. When you run Console now you should get something like this

IPython is working now directly from the "command window", which means you can execute any Python commands and some system commands with history and TAB completion.
System commands have to start with exclamation mark


The window can be exited with CTRL-D.

15 komentářů:

Kaizen řekl(a)...

Good article!!!

I've to do something more to work: in the directory "site-packages" where you copy "pyreadline/Ipython", edit "syspaths.pth" and add the name of the directories:

pyreadline
IPython

I used the version 2.00.127 of Console, because the last works bad for me.

Regards.

rdk řekl(a)...

I am using the version 2.00.129 of Console without troubles.

I even realized that there are some direct system commands, such as ls, cd, etc. where exclamation mark is not needed.

syspaths.pth should not be needed when the site-packages is on the PYTHONPATH.

Btw. PYTHONPATH can be checked from within the Python by:

import sys
sys.path

On the other hand I got quite used to use .pth files to point outside of the Python directory. Unfortunately .pth seems not to work with PortablePython.

Radek

Mark řekl(a)...

Ive got this all set up and working but it wont let me run runserver and other python commands ?


Also how would i access the cmd for sqllite as that isnt covered in the django tutorial ?

Thanks

rdk řekl(a)...

Mark, you can run Python commands directly (eg. print "Hello funny World" ).

In case you need to run something.py with clean namespace, just type:
run something

.py extension is added automaticaly.

Radek

Kaizen řekl(a)...

If I want to use the "SciTE.exe" editor that comes with PortablePython, how I do it?

Editing "IPython\UserConfig\ipythonrc" with relative paths (f.e. "..\..\..\SciTE.exe") didn't work, because it uses ipythonrc of my settings directory. How I can change this? how I can change the behaviour of "IPython" to use the config file that I want?

Mark řekl(a)...

Hello again.

Sorry i meant running dango commands like

python manage.py runserver
python manage.py syncdb

I cant get these to work directlt from the console.

rdk řekl(a)...

Kaizen, I have not been using Scite, even though it comes with Portable Python. I will look at that and let you know.

Mark, I do not run these commands directly, ie. I have some intermediate batches, that cover some settings (I will try to cover that in some next post). However I assume, that you can run them in the way:

run manage runserver

run manage syncdb

Of course you need to cd into the project folder, where manage.py is.

Kaizen řekl(a)...

Ok, take your time. Thanks and regards.

rdk řekl(a)...

"""If I want to use the "SciTE.exe" editor that comes with PortablePython, how I do it?"""

Kaizen,

I have looked at Scite, but still do not know what you really want to do.

Scite.exe is the editor, which can be run directly from Windows Explorer. So there is no need to run it from within IPython "command line".
Of course Scite is not IDLE, which comes with Python shell - interpreter input window. Scite is capturing only output from running scripts.

The properties for Scite are stored in the Portable Python folder.

"""how I can change the behaviour of "IPython" to use the config file that I want?"""

In the Console configuration change the command as: ..\python\python.exe ..\python\SCRIPTS\ipython -ipythondir ..\settings

Before you run the IPython, copy content of the _ipython folder in your profile into the settings folder located in this case at: L:\devtools\settings

Hope this helps.

Radek

Kaizen řekl(a)...

Thanks!. I modified the editor line putting relative paths from "console directory" to "SciTe.exe", and works flawlessly.

I don't want to replace IPython shell function. I want to replace the window's notepad function: everytime I launch "%edit something.py", it's boring to see a plain text without syntax highlighted :)

Thanks for everything and regards.
Andrés Suárez.

Anonymní řekl(a)...

Great article! Thanx it's a life saver :)

Anonymní řekl(a)...

Bonjorno, translatecz.svarz.cz!
Vorrei suggerirvi di fare generici ed acquista cialis meno costose per i suoi [url=http://farmamed.fora.pl/ ]Dove Compra cialis [/url] aquisto cialis generico bici corsa specialized bici da corsa specialized [url=http://farmitalia.fora.pl/ ]Dove Comprare cialis generico[/url] a casa tua, ovunque nel mondo! Facile processo d'ordine online Nessun costo [url=http://milanofarma.fora.pl/ ]Come Compra cialis generico[/url] rinascere. Spediamo gratis in Italia Isole comprese [url=http://farmanova.fora.pl/ ]Come Comprare cialis generico[/url] comprare cialis tadalafil. acquisto viagra sildenafil. [url=http://farmaroma.fora.pl/ ]Come Compra cialis generico[/url]

Anonymní řekl(a)...

Jetzt kann ich an der Diskussion nicht teilnehmen - es gibt keine freie Zeit. Ich werde frei sein - unbedingt werde ich die Meinung aussprechen. cialis cialis kaufen [url=http//t7-isis.org]levitra 20mg[/url]

Anonymní řekl(a)...

http://markonzo.edu ezetimibe side effects armen paxil side effects miami metronidazole side effects revelling ltda augmentin side effects pleaded deepening diflucan side effects slicing opportunites

Anonymní řekl(a)...

the singles [url=http://loveepicentre.com/]singles holidays[/url] bbw personals plus http://loveepicentre.com/ jewish single dating service