And*_*raD 6 postgresql anaconda conda
作为Anaconda的新手,我在正确设置conda环境方面遇到了一些麻烦。我感兴趣的是为带有postgres数据库的Django应用程序搭建环境。以下命令创建环境:
$ conda create -n django1.7-webdev python=3.4 django=1.7 postgresql=9.1
Run Code Online (Sandbox Code Playgroud)
第二条命令激活环境:
$ source activate django1.7-webdev
Run Code Online (Sandbox Code Playgroud)
但是,此时,当尝试运行psql时,出现以下错误:
$ 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"?
Run Code Online (Sandbox Code Playgroud)
如何在conda环境中启动PostgreSQL?以下命令启动在激活的conda环境之外安装的PostgreSQL,这不是我想要的:
$ sudo service postgresql start
Run Code Online (Sandbox Code Playgroud)
有关启动服务器的 postgresql 文档位于https://www.postgresql.org/docs/9.1/static/server-start.html - 在此之前,您可能还需要初始化数据库:https://www.postgresql。 org/docs/9.1/static/creating-cluster.html
conda 包应包含遵循这些指示所需的任何二进制文件。此外,这些二进制文件应该已经在 PATH 中,因为您正在激活环境。
一般来说,如果您使用 sudo 启动命令来与 conda 交互,那么就会出现问题。除非您尝试进行一些由多个用户使用的集中安装,否则 conda 永远不需要管理员权限。