PostgreSQL이 개발 시스템에 설치되지 않은 경우 psycopg2를 virtualenv에 설치
그것은 설치할 수 있습니다 psycopg2
에 virtualenv
PostgreSQL을가 OS X 10.6와 프로 내 개발 시스템 맥북에 설치되어 있지 않은 경우?
pip install psycopg2
내에서 실행할 때 virtualenv
아래와 같은 오류가 발생했습니다.
Django를 사용하여 서버의 레거시 데이터베이스에 연결하려고하는데 가능하면 개발 시스템에 PostgreSQL을 설치하지 않는 것이 좋습니다.
PostgreSQL을 설치하지 않는 이유는 무엇입니까?
homebrew를 사용하여 PostgreSQL을 설치할 때 오류가 발생했습니다. MacBook Pro에 Xcode4 (Xcode4 만)가 설치되어 있으며 gcc 4.0이 누락 된 것과 관련이 있다고 생각합니다. 그러나 이것은 다른 StackOverflow 질문에 대한 문제입니다.
2011 년 4 월 12 일 오전 8:37 업데이트 : MacBook Pro에 PostgreSQL을 설치하지 않고도 이것이 가능한지 알고 싶습니다. 그러나 나는 brew update
ossp-uuid를 실행 하고 강제로 재설치 brew install --force ossp-uuid
했으며 이제 brew install postgresql
작동합니다. PostgreSQL이 성공적으로 설치 pip install psycopg2
되었으므로 내 virtualenv 내에서 할 수있었습니다 .
오류 pip install psycopg2
$ pip install psycopg2
Downloading/unpacking psycopg2
Running setup.py egg_info for package psycopg2
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
Complete output from command python setup.py egg_info:
running egg_info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /Users/matthew/.pip/pip.log
예비 조사
다음은 제가 예비 조사로 읽은 기사입니다.
- OS X에서 PostgreSQL과 함께 Django를 사용하기 위해 psycopg2 설치
- OS X에 psycopg2 설치
- Ubuntu JauntyLucid에서 virtualenv와 함께 psycopg2 사용
- Postgres, psycopg2, virtualenv 설치 힌트
psycopg는 pg_config
명령에 따라 다르며 명령이 없으면 psycopg를 설치할 수 없습니다.
If system installation is a problem to you, why don't you try compiling PostgreSQL and including generated bin files in your $PATH? Like:
export PATH=/path/to/compiled/postgresql/bin:"$PATH"
pip install psycopg2
apt-get install libpq-dev
helped me on debian squeeze
apt-get install libpq-dev
helped me in debian squeeze too . After that do pip install psycopg2. I faced problem of pg_config not found problem when i was setting up my environment on heroku , now its working fine .
You need to install the python-dev
package in order to make use of python extensions such as psycopg2
. I don't know how to install packages in mac but I run the following commands to install a python package on my Ubuntu machine.
sudo apt-get install python-dev
Or
sudo apt-get install python3-dev
if you are using Python3.x.
Once the installation is finished run the following command within your virtual environment.
pip install psycopg2
You don't need the complete PostgreSQL installed: you only need the client side libraries.
brew install postgresql
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
pip3 install psycopg2
I solved it in MAC OSX using :
$ wget https://ftp.postgresql.org/pub/source/v9.5.3/postgresql-9.5.3.tar.bz2
$ tar xfv postgresql-9.5.3.tar.bz2
$ cd postgresql-9.5.3
$ ./configure
$ make
$ cd src/bin/pg_config
$ export PATH=`pwd`:"$PATH"
$ pip install psycopg2
Using the method you described in your April 12th update, I was able to install PostgreSQL(+1). Note that I originally was running Python 2.7.1 (32bit) and homebrew threw several errors and warnings regarding using a 32bit version of Python. I have since switched the 64/32 bit version of 2.7.1 and it works like a champ.
Regarding the pyscopg2, I was able to install it into my virtual environment from source by editing setup.cfg. I set pg_config to correct path inside homebrew's Cellar (pg_config=/usr/local/Cellar/postgresql/9.0.4/bin/pg_config). After saving the changes, I ran python setup.py install with zero issues. It's worth noting that I did not set the Mac's default python setting to 32 bit. I used the new 64 bit from start to finish.
After looking over some of the documentation, I think if I added homebrew's postgresql path to the system path I could have used pip to install it.
Reference:
http://favosdream.blogspot.com/2009/09/make-psycopg2-and-readline-work-in-snow.html
Update 6-8-2011:
While porting a project written on OS X to Windows 7, I found out that I had to install PostgreSQL on Windows as well. This ended up creating another user on my start up screen and other things that I just didn't like. While doing some digging I found Windows drivers for PostgreSQL here. I have since uninstalled the full PostgreSQL and installed the ODBC drivers which, thus far, work great.
To address the original question, after doing a bit more digging I think I found the equivalent ODBC for OS X here. I have not had a chance to try them out, but the concept works very well on Windows 7. I will update this when I get a chance to try them out. Until then, I hope this helps.
As I never needed to install postgresql database on this server I installed the following libraries on Ubuntu 14_04 version before running pip install psycopg2 on the same server
apt-get install libpq-dev python-dev and then executed pip install psycopg2 within virtual env.
Output Collecting psycopg2 Using cached psycopg2-2.6.1.tar.gz Building wheels for collected packages: psycopg2 Running setup.py bdist_wheel for psycopg2 Stored in directory: /root/.cache/pip/wheels/e2/9a/5e/7b620848bbc7cfb9084aafea077be11618c2b5067bd532f329 Successfully built psycopg2 Installing collected packages: psycopg2 Successfully installed psycopg2-2.6.1
'Program Tip' 카테고리의 다른 글
VB.Net 속성-Public Get, Private Set (0) | 2020.11.23 |
---|---|
유니 코드 문자의 코드를 어떻게 얻을 수 있습니까? (0) | 2020.11.23 |
MySql에 대한 샘플 MongoDB 데이터베이스가 전 세계에 있습니까? (0) | 2020.11.23 |
Android에서 텍스트 편집에서 커서 위치를 얻습니까? (0) | 2020.11.23 |
std :: async를 사용해야하는 이유는 무엇입니까? (0) | 2020.11.23 |