Monday, April 30, 2012

virtualenvwrapper on Ubuntu 12.04

If you use Ubuntu, you were probably pretty excited when you turned on your machine this week and a window popped up asking if you'd like to upgrade to Precise Pangolin.

Of course there are many new things to explore. After I upgraded, one thing I noticed, is that virtualenvwrapper.sh is not in /usr/bin or anywhere in /usr/lib/python2.7 actually it's in /etc/bash_completion.d/virtualenvwrapper. It seems as if this script has actually bounced around a fair bit. In Ubuntu 9.04 it was in /usr/local/bin/virtualenvwrapper_bashrc. And of course it depends on how you installed it. If you used pip then it will install in /usr/local/bin (also see this), as if you were on a generic Linux (non-Debian) box.

Update (2012-05-01): See the source on Launchpad for yourself:

In contrast to the information in
/usr/share/doc/virtualenvwrapper/en/html/index.html this package installs
virtualenvwrapper.sh as /etc/bash_completion.d/virtualenvwrapper.
Virtualenvwrapper is enabled if you install the package bash-completion and
enable bash completion support in /etc/bash.bashrc or your ~/.bashrc.
If you only want to use virtualenvwrapper you may just add
 source /etc/bash_completion.d/virtualenvwrapper
to your ~/.bashrc.

One of the implications of this is that the first time you start your terminal after instlalling virtualenvwrapper, it will run the virtualenvwrapper shell script in your bash completion directory. If you have not already set up a $WORKON directory, it will automatically set this to ~/.virtualenvs. It doesn't set the $PROJECT_HOME variable though. You can still add export WORKON_HOME=/path/to/your/virtualenvs to your .bashrc, .profile, .bash_profile, etc. (whichever applies to you). But it is obviously not necessary to add source /path/to/virtualenvwrapper.sh, since this file doesn't exist! And the virtualenvwrapper shell script will automatically run every time you start your terminal already because it is in the bash completion folder which is called indirectly from your global bashrc file (might be bash.bashrc or something else). file in /etc. Because .virtualenvs starts with a dot, Ubuntu will probably hide it so use control-H to reveal hidden folders and files in your file browser (probably Nautilus) or la (ls -A) in the terminal.

The upshot of this, is unless you want to set a project folder for virtualenvwrapper, you can start using it the instantly without any setup or murky .bashrc edits. Enjoy!

Thursday, April 26, 2012

VirtualBox hates small machines

Don't bother installing VirtualBox on a machine with anything less than 2GB of RAM. VMWare Player 3.5 is still downloadable, and works great with older systems. It will run with up to 75% of your physical memory, whereas VirtualBox will not allow you to use more than half. This will let you install Fedora 16 which needs 786MB to install, even LXDE or XFCE. After installation I turned it back down to 512MB.

Otherwise VirtualBox is awesome on new-ish boxes. I have it on my Dell Core 2 Duo (cerca 2007) with 2GB running Ubuntu 12.04LTS.

Mount cd0

Trying to build vmware tools for bsd. Need to mount CD? Try this

mount -t cd9600 /dev/cd0 /cdrom

Thursday, April 19, 2012

Bad BSD

I wanted to try BSD because of it's historical connection to the original UNIX system developed at Bell Labs. I love this chart (courtesy of Wikipedia) that shows the web of OS development.
I downloaded FreeBSD which installs nicely in VMWare Player and VirtualBox. When installing make sure to add yourself as a user, and make sure to add yourself to the wheel group. This will make it possible for you to use su which you'll need to install packages. If you didn't add yourself as a user during the installation, don't worry, login as root, type adduser and answer the questions. Accept the default for almost everything, except, of course, add yourself to the wheel group. If you didn't add yourself to wheel then you need to logout (hit ctrl-D or type exit) and login as root, then type

$pw usermod username -G wheel

and now you can use su, which lets you login as root to install your package, then return to your shell when you exit.

To install packages, so far, I've been using pkg_add -r package-name. This downloads the pre-compiled package from a BSD repo. BSD also gives you the option to build packages from source, called ports, and you can download the complete ports during installation. There is a good section in the BSD handbook on the pros and cons of both.

Thanks nixCraft for helping me understand su.

Tuesday, April 17, 2012

KDE the double deuce of desktops

KDE is so tricked out you might not even be able to install it, let alone run it. It's like Windows 7 for linux. It takes too much ram. Wouldn't install on my VM's. Barely got Ubuntu KDE on VMWare, but wouldn't work on VirtualBox. I did get KDE running on bad, but it's an older version. My 2nd bad KDE experience.

do not delete your windows temp files!

your temp folder (you can find it by it's environmental variable %TEMP% or %TMP%, probably in your local settings folder, might have some important files! I deleted them, and then had a problem installing VS2010 SP1. There were some posts that showed how to fix it, but the gist was uninstall and reinstall so that your temp folder would have the right files. Ugh

Monday, April 16, 2012

Resize VirtualBox hard disk drive

Numerous post cover how easily this can be done.

$ sudo vboxmanage modifyhd filename --resize size-in-MB

There is a catch, and I'm not sure why, but your VM may not recognize the new unallocated space if there are snapshots, so make a clone first and work with that.

Extending your partition in Windows XP is a little more work. If you are not extending the system partition, Windows XP can handle it using diskpart. Otherwise there are numerous partition managers (listed in no particular order) such as EaseUS Partition Master, Aomei Partition Assistant, Mini Tool Partition Wizard (which also has a live CD for download), and GParted Live. Here's a recent review with a few others.

All of these except the last (two, if you include Mini Tool) must be installed first. I chose GParted Live because I did not want to install any more software on my VM than necessary, and I didn't want to uninstall it either. Also it's easy enough for me to reboot my VM using any ISO image on my host. GParted Live is an ISO image of a mini Debian X11 system with Gparted, the partitioning tool. It has everything you need to manage your partitions on any platform. All of the files in the dependencies for each platform are in the ISO image.

As always there are caveats. Before you edit your partitions obviously back up any data. But you already did that by making a clone of your VM. Now defragment then run CHKDSK /f on your old volume. This is to make sure the disk sectors are properly accounted. Otherwise GParted won't know where they are and will fail. Don't worry, if this happens your disks will not be altered, and GParted tells you to do what I just said above. The rest is pretty obvious.
Fork me on GitHub