Cant find pg_config even after installing Postgres 9.5 - python

I have been trying to debug this for quite a while now (and read lots of related Q/A on StackOverflow) but unable to figure this out.
Trying to setup Django on my Mac OS X 10.11.6. I followed the detailed tutorial. This is what I did:
1) Installed Python 3.5.2 (by directly downloading the package from the Python web site and running it).
2) Installed PostGres 9.5 using the fink package (fink install postgresql95)
3) Installed psycopg2 using the fink package (fink install psycopg2-py35).
4) Updated pip.
5) Setup a virtual environment and activated it.
6) After activating the environment, installed Django (via pip).
Next, when I tried to setup a sample app in the environment and ran python manage.py migrate, it gave me the error : Error loading psycopg2 module: No module named 'psycopg2'
After reading a lot of posts on StackOverflow, it seemed that I have to install psycopg2 again within the virtualenv (and for some reason, I cant use Fink again?). So as suggested on some posts, I tried to install it using:
pip install psycopg2
Got this error:Error: pg_config executable not found.
I am sure my Fink install of Postgres 9.5 was successful earlier, so I tried to search for pg_config from root dir:
sudo find . -name "pg_config"
But it returned nothing!
My question is, is it possible that fink package did not come with pg_config? If it didnt, is my only option now to uninstall postgres and install it with another package? (FYI: I was able to start PostGres and create a user and a database on it already)
Thanks in advance,
Anupam
Update: After waiting a while to get answers from SO, I gave up and just uninstalled the postgres fink package. Then installed the postgres.app instead, on my mac. Working fine for me. The command python manage.py migrate worked fine for me this time and the psycopg2 installation also went fine (with pip). I wonder why the psycopg2 installation page (http://initd.org/psycopg/docs/install.html#installation) only mentions Fink and MacPorts as the installation options especially when the Fink packages dont seem to be very reliable. I had posted a message on the Fink users group also about improving the installation documentation in another context but didnt get a response : (

Related

Mac pip install pyodbc fails with library not found for -lodbc

So I've been going in circles looking for answers to this and it seems to be a problem very specific to my situation.
I am trying to get a Python Django project connecting to an Azure SQL Database with the ODBC 17 Driver.
I have used brew to install msodbcsql17 and mssql-tools.
I have created a virtualenv using pip install virtualenv and python3 -m venv env
After activating this virtual environment with source ./env/bin/activate and trying pip install pyodbc I get this error:
ld: library not found for -lodbc
I'm guessing this is some sort of PATH issue, but I'm ignorant on how to debug it or correct it.
Any information on how to properly set up Python and Django on Mac OS 11.4 to work with Azure SQL database in a virtual environment would be much appreciated, because everything I have tried os far has led me to similar dead ends with libraries not being found or loaded one way or another.
Edit 1:
So I've discovered from https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver15 that ODBC does not support M1, which I realize now is what my laptop has... so this may be the underlying issue for all the problems I've been encountering.

Mysqlclient fails to install

I am trying to install mysqlclient on mac to use mysql in a django project. I have made sure that setup tools is installed and that mysql connector c is installed as well. I keep getting the error Command "python setup.py egg_info" failed with error code 1 in. This is my first django project since switching from rails. Is there something I am missing? I am using python 3 and I use pip install mysqlclient.
I was able to fix this by running pip install mysql. I do not understand why this worked because I already had MySQL installed on my system and had been using it.
I am going to assume it is because Python uses environments and MySQL wasn't installed in the environment but I would like to know for sure.

How to get LBForum (0.9.22) to run

I've installed and configured the Django app LBForum on Windows 8.1 and cannot get it to run. My ultimate goal is to get it to run alongside Mezzanine, but I can't even get it to run on its own.
Here's what I've done:
(As a precondition to the following steps, I have the following C/C++ compiler installed to support pip. http://www.microsoft.com/en-us/download/details.aspx?id=44266. The batch file vcvarsall.bat is on the path environment variable.)
Perform a fresh install of python 2.78. I used the ActiveState distribution 64 bit.
I then uninstall and reinstall virtualenv because of a bug as per these instructions (https://askubuntu.com/questions/400343/trying-to-create-a-python-virtual-environment-but-getting-oserror)
Next I activate the new environment env\Scripts\activate.bat
Next install lbform with pip install lbforum which fails because of "PIL" so I install that by itself. pip install PIL --allow-unverified PIL --allow-all-external per Installing PIL with pip.
Then install lbform with pip install lbforum which seems to work fine as it reports success
Next I use the standard django commands for creating a site and adding a project.
I update the urls.py and the settings file for the site per the instructions found here: https://github.com/vicalloy/LBForum. Leaving off step 7.
When I run the app I see the following errors:
RuntimeError: South does not support Django 1.7 or higher. Please use native Django migrations.
I get different errors when running along Mezzanine but I'll create a different question for that once I know how to get this to run stand along in its own virtualenv.
Update: I've made some progress on this by removing south from INSTALLED_APPS. After doing so I was able to run .\manage.py migrate successfully. However I know see other errors:
File "c:\Users\cmedcoff\envlbf\lib\site-packages\attachments\urls.py" in <module>
1. from django.conf.urls.defaults import patterns, url
Exception Type: ImportError at /
Exception Value: No module named defaults
Apparently the package django-lb-attachments (0.8.3) is looking for the package/module "django.conf.urls.defaults" which does not exists in version Django (1.7.7)? So I guess lbforum docs suggest that Django 1.3+ is supported but this is not the case for 1.7.7 without import edits?
The problem when you install lbforum which in pypi last update was on 2011.
The project has set the Django dependency as Django>=1.3, so it will install Django 1.7 :S.
Similar thing happends with PIL, you should install Pillow instead of PIL.
Also this project seems to be incompatible with Django 1.5 and has some out dated deps
I think you need to follow this steps (I tried them on linux)
pip install Django==1.3
However I will recommend to use the latest version of Django.
you can try to install dev version with this command (you will need git), but it seems to be not compatible with Django 1.5
pip install git+https://github.com/vicalloy/LBForum
Tehere is a fork which it seems to be compatible with Django 1.5+, but I didn't have time to check it.
pip install git+https://github.com/bjinwright/LBForum
check it here
For installing Pillow instead of PIL
pip uninstall PIL
pip install Pillow

Cannot install modules with anaconda installed

I installed anaconda a little while ago. Later I installed django. Django was the first program I could install successfully and run without error.
I just tried to install mysqldb with the following:
sudo apt-get install python-mysqldb
and it gave following message:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-mysqldb is already the newest version.
The following packages were automatically installed and are no longer required:
linux-headers-3.5.0-17 linux-headers-3.5.0-17-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
If I run a django app configure to have a mysql back-end I get
ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
I think this has something to do with having anaconda installed. I'm running on ubuntu OS.
Does anyone know how I can get mysqldb module to get recognized by django?
It looks like all my anaconda modules are in:
/home/aiden/anaconda/lib/python2.7
I think my django lives in:
/home/aiden/django/
and i searched for mysqldb and found a file under anaconda:
/home/aiden/anaconda/lib/python2.7/site-packages/sqlalchemy/something.../drizzle/mysqldb.py
I don't know how to check where I installed things to, but I think that mysqldb isn't getting installed b/c it's already somewhere in anaconda
apt-get is going to install things into the system Python. To install things into Anaconda, you need to use the conda package manager, assuming the package is build for conda already, or else build from source. You can also try to find the package on binstar.org if there isn't one in conda already.
I just ran a "conda install bottle" but it didn't have the package available, but it automatically installed bottle using pip. This works fine. Anaconda is great.

Error installing psycopg2 on Windows using pip and virtualenv

I'm following Heroku's "Getting started with Django on Heroku" article and am getting a long series of errors on "pip install psycopg2". Django 1.4.3 and PostgreSQL 9.2.2 are already installed, and yes, the postgres \bin\ directory is on the PATH.
Any ideas?
It doesn't look like Psycopg on Windows is as simple as using pip. The Psycopg website recommends using these Windows builds.
As a windows users running through the Python Getting Started tutorial on Heroku I ran into a similar issue. I found pycopg2 here: http://www.stickpeople.com/projects/python/win-psycopg/
And then used easy_install in the virtual env directory.

Categories

Resources