So far as I know, no, you don't HAVE to have stuff in the cgi-bin folder. That's the traditional place for Perl, and others picked it up.
Modern use of Python use wsgi (web server gateway interface) and Ruby's got Rack and Perl's got the similar Plack (works with psgi, Perl's version of wsgi). Okay, these are more for "web applications" than web scripts, but then again, what's the difference?
Or does it HAVE to be in the CGI directory?
I believe so long as your server is configured correctly and knows where the scripts are and where the files are the script should be calling, you can put your programs anywhere you want (within reason). You can also have stuff in a folder called cgi-bin but use mod-rewrite to remove that from urls (if that's the issue, tho it doesn't sound like it).