Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres in Conda Environment (Ubuntu 14.04)

Being new to Anaconda, I am having some trouble properly setting up a conda environment. What I am interested in achieving is setting up an environment for a django application with a postgres database. The following command creates the environment:

$ conda create -n django1.7-webdev python=3.4 django=1.7 postgresql=9.1

This second command activates the environment:

$ source activate django1.7-webdev

At this point, though, when trying to run psql, I get the following error:

$ psql
psql: 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"?

How can I start PostgreSQL in the conda environment? The following command starts the PostgreSQL installed outside the activated conda environment, which is not what I want:

$ sudo service postgresql start
like image 711
AndraD Avatar asked Jun 08 '15 22:06

AndraD


1 Answers

The postgresql documentation on starting servers is at https://www.postgresql.org/docs/9.1/static/server-start.html - before that, you might also need to initialize a database: https://www.postgresql.org/docs/9.1/static/creating-cluster.html

The conda package should include any binaries necessary to follow those directions. Moreover, these binaries should already be on PATH, since you are activating the environment.

In general, if you're starting a command with sudo to interact with conda, something is wrong. Unless you are trying to do some centrally-owned install that several users use, conda should never require admin rights.

like image 76
msarahan Avatar answered Nov 01 '22 07:11

msarahan