Installing PostGIS on Windows - django

I've installed PostgreSQL and PostGIS, and now I'm trying to follow these instructions:
http://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#spatialdb-template
But I keep getting the following error, both in the command prompt and in Cygwin:
C:\Users\Home>createdb -E UTF8 template_postgis
createdb: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
And I know PostgreSQL is running, because I'm using it right now!
Installing open source applications can sometimes be so frustrating...
I'll be very grateful for your help!

Are you by any chance using cygwin here? Particuarly, is the system picking up createdb from a cygwin binary?
If your server is cygwin, try removing it and replace it with the Windows version.
If your server is the Windows version, but you have createdb from a cygwin install in the PATH, try removing cygwin from your PATH to make sure you pick up the Windows version of createdb.

Related

Launching anaconda spyder gui in cygwin

I am connecting my windows 7 computer to a linux based cluster using cygwin. Within a specific node in the cluster I want to launch the anaconda spyder gui.
to launch spyder you simply type:
spyder into cygwin
but that returns:
QXcbConnection: Could not connect to display
Aborted (core dumped)
I also tried:
QTA_QPA_PLATFORM=offscreen spyder
but that returns:
QFontDatabase: Cannot find font directory /home/spotter/anaconda2/lib/fonts - is Qt installed correctly?
I installed qt4 dev-tools but it didn't change anything
EDIT:
I installed xinit and xorg and now I try this:
before logging in with ssh i run:
export DISPLAY=localhost:0.0
then I login using ssh:
ssh -Y -X usrname#machine
and now when I try to use spyder I get:
connect localhost port 6000: Connection refused
QXcbConnection: Could not connect to display localhost:11.0
So it sounds like you are running Cygwin on your local Windows machine, logging into a remote server with ssh, and running spyder from that machine with the intent of having it show up on your local screen. Now that you have startx working, you are close to a solution.
Between steps 5 and 6, you need to run the export DISPLAY command on the remote machine and set it to the name of your local computer. You will need to know your hostname for this. The steps will look like this:
startx
ssh -Y -X username#machine
export DISPLAY=win-machine-name:0.0
spyder
The last two commands are executed on the remote machine. I just made up the win-machine-name. In its place, you will put the IP address or machine name of your windows machine. That is how you tell set the DISPLAY environment variable on the remote machine, so X clients know where to send the graphics commands.
Hope this helps!
For me what I did was:
Install packages associated with startx
Change the sshd_config file to allow X11 forwarding
export DISPLAY=localhost:0.0
startx
login with ssh -Y -X username#machine
spyder

Syntax error when trying to run debug configuration for remote interpretor from PyCharm

I'm setting up a Google App Engine Django project to run in a Vagrant environment for easy setup/teardown of the system and am using PyCharm as the IDE for it all. I'm able to successfully get the server to run using PyCharm on the remote machine, but if I try to use the remote debugger to start a debug session, PyCharm gives me a nondescript error:
Error running webapp: Can't run remote python interpreter: Couldn't obtain remote socket from output , stderr File "", line 1
import
^
SyntaxError: invalid syntax
I'll try to include as much info about the setup as I can:
Windows 10 host machine, Ubuntu 14.04 guest
Python is version 2.7.10
/home/vagrant/www/shell/python-su.sh setup as python interpreter. Just passing arguments to sudo /usr/bin/python $# to make it work in vagrant/GAE
GAE Directory in PyCharm is set to /home/vagrant/google_appengine/ to make it work on the remote machine
Here's a screenshot of my PyCharm Configuration Settings for launching debug client:
All of this matches what I do for the run configuration and that works fine. It's only the debug configuration throwing this error.
From the help documentation for PyCharm, I found this article detailing how to turn on more logging to the PyCharm log file. Add this to the log.xml file located in the /bin/ directory of the PyCharm Program Files directory:
<category name="#com.jetbrains.plugins.webDeployment">
<priority value="DEBUG"/>
</category>
Looking at the log file showed what command it was trying to run, which I was able to run by SSH-ing into the machine to run it myself. From there, I was able to figure it it was coming from my sudo python file. I had to wrap the $# in quotes to get it to work properly. The run was working because the arguments were simple enough that it didn't matter that it wasn't quoted. The final python sudo shell file looks like this:
sudo /usr/bin/python "$#"

Postgres 9.3 could not connect to server

Running into the a similar issue as that mentioned here Postgres could not connect to server
I am trying to run rake db:create on a rails 4.1.4 project. I have tried everything mentioned in the previous post - any other suggestions are welcome.
Furthermore, after reinstalling postgres, I ran the command
brew info postgresql and got this Conflicts with: postgres-xc (though I'm not sure if this is relevant). I'm running postgres 9.3.4
Any help will be greatly appreciated...Thanks!
Update: This is the exact error:
could not connect to server: Socket operation on non-socket
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Things I've tried so far:
brew uninstall postgresql
brew update
brew upgrade
brew install postgresql
followed by the list of commands here http://www.postgresql.org/docs/9.3/static/server-start.html
Finally, using the lunchy gem to start postgres worked - http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/
Finally, using the lunchy gem to start postgres worked -
http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/Thanks

Django PostGIS Locally Installing / Running

I'm trying to follow the steps listed here to get PostGIS working with Postgresql and Django on 0SX 10.8 Mountain Lion. However, when I get to step 6: createdb -U USERNAME -E utf8 geodjango I get an error:
createdb: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
How can I move forward with the installation process here? Is this the right method? Thanks for your ideas!

Postgresql socket error on OSX 10.7.3 when running Django's syncdb

Since upgrading OSX to version 10.7.3, when I attempt to run a Django "syncdb" command, I receive the following psycopg2 error from Postgresql 8.4.2:
psycopg2.OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
I'm able to open psql without incident, but when I attempt to run "pg_ctl status", I receive this error as well:
pg_ctl: could not open PID file "/Library/PostgreSQL/8.4/data/postmaster.pid": Permission denied
Is there a correlation?
I had the same problem too: updated osx to 10.7.3 and after I restarted the postgres server I got the same issue when I tried to run $ ./manage.py dbshell that goes through psycopg2, but didn't have problem connecting to postgres using psql.
To me the problem appears to be related just to "connections on Unix domain socket", because psycopg2 uses the newly 10.7.3 osx updated postgres library.
I tried to reinstall psycopg2, but nothing was changed.
So, I changed the HOST value on the databases section of my django settings.py, and instead of having an empty string I put 'localhost'.
and it works perfectly!
Eelke 's problem was the same as mine.
The quickest fix for this would be to add
export PGHOST=/tmp
an environment variable in your .bashrc/.zshrc/etc
file (depending on which you use).
The best fix would be to set the specific path in your apps config file.
Did a bit of testing on my Mac and I noticed that there are two versions on my system for several commands. One version is in /usr/bin the other is in /Library/PostgreSQL/9.0/bin. The version in /usr/bin is expecting /var/pgsql_socket/.s.PGSQL.5432, the right version for my install expects /tmp/.s.PGSQL.5432
The version in /usr/bin is 9.0.5 and it has been installed by Apple.
Unfortunatly I do not know much about django, but my bet is it is either calling a command in the wrong path or it is loading a library from the wrong location.
You can fix the problem by creating a symlink:
ln -s /tmp/.s.PGSQL.5432 /var/pgsql_socket/
This did the trick for me in the end...
Change the HOST value in the database dictionary in settings.py to this:
'HOST': '/tmp',
Source:
http://jeffammons.net/2011/09/fixing-postgres-on-mac-10-7-tiger-for-django
Reinstalling psycopg2 worked for me
I ran into the same issue just after upgrading to OSX 10.7.3; reinstalling PostgreSQL solved the problem and did not delete my existing data.