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.
Related
I need to upgrade the sqlite3 version that my python 3 uses but there seems to be no clear answers and I don't understand what determines the version of sqlite3 used by python. I am running CentOS7 with python 3.6.4 installed. CentOS had sqlite version 3.7.17 installed and I upgraded this to 3.23.1 thinking python would also use this never version of sqlite.
import sqlite3
print(sqlite3.sqlite_version)
The following code still gives me 3.17. I have googled how to upgrade the version but most solutions seem to refer to pysqlite which is python 2 only. Other solutions talk about complicated compiling processes that go way over my head.
I don't understand what determines the sqlite version that python uses. Is it determined by the python version, OS installed sqlite version? I am also running python 3.6.4 on my windows PC and it says I am running 3.14.2 so it seems that the sqlite version does not depend on the python version.
What determines the sqlite version python uses? Is there not a more straight forward way to upgrade the sqlite version for python 3?
sqlite3 is kind of external library.
so, you need to set external library path.
try next command
printenv LD_LIBRARY_PATH
result will be empty, if you never set before.
next command will work using installed sqlite3 for python
export LD_LIBRARY_PATH="/usr/local/lib"
then, you can execute and get correct version you installed
import sqlite3
print(sqlite3.sqlite_version)
but this method will be reset when you logout and login again.
so, if you want to do regist that environment variable every time you login, you should edit /etc/profile
sudo vi /etc/profile
and add export code
export LD_LIBRARY_PATH="/usr/local/lib"
then, if you log-out and log-in again, you can see LD_LIBRARY_PATH is registered.
In Ubuntu, you can add dqlite repository and update it using apt.
sudo add-apt-repository -y ppa:dqlite/stable
sudo apt update
sudo apt install sqlite3
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 : (
I have some pyhton-scripts which are working perfectly on my local computer, but as you would guess, not so good on the server!
I wanted to use "pythonbrew" since at the server I have only Python 2.7.6 installed, but I need hdf5-package running ... OK
I installed pythonbrew (according to https://pypi.python.org/pypi/pythonbrew/) and switched to version 2.7.10 (as I use on my local computer).
Now I got some "numpy-issues". So I installed numpy with pip successfully (according to How do you install numpy when you're not a superuser? and https://gist.github.com/audy/4012573), however, when I am running the programme:
pythonbrew py startup.py
I got the error message saying numpy was not found ...
I really have no clue what I am missing here? I appreciate any help!
I found out myself how to run a python script with pythonbrew properly!
According installation guide for pythonbrew (see: https://pypi.python.org/pypi/pythonbrew/), the following line should be used to run a script:
pythonbrew py myprogramm.py
However, I can run my script by using python instead of pythonbrew py:
python myprogramm.py
I cannot give an explanation for that, sorry. But maybe other people can. It is just working very well like this and I can use python and all packages normally!
Further instructions of how to use pythonbrew, installing or switching between different version etc., see the link to the installation guide I posted above!
More details about pythonbrew and usage (from my perspective of view):
The installation guide I mentioned explains step by step how to install pythonbrew in your home directory (e.g. on a server) and helps to set up python on a system where you are not superuser (e.g. a server where you are allowed to run scripts but not to execute any further installations!).
I had the problem that I needed a more up to date python-version and the server where the data is located is equipped with an older version. The other half of the story is that I also needed some packages (e.g. h5py or cosmolopy) which are also not installed at the server.
For me the easiest and perfectly working solution to that problems was to use pythonbrew and install it at my home directory on the server!
I am trying to establish MYSQL connection with my twisted server script. I found out that txMYSQL is a good choice to use, I dowloaded the package out of Github and tried installing from the setup.py file, but it didn't work.
I tried inslalling txMYSQL by using easy_install txmysql but it dosen't appear to be found through this command since its not on pythons server.
How can I install txMYSQL ?
I am currently using python 2.7.8 on my Windows machine.
Try to install using pip and referencing Github repo. I tried here and worked well on a Ubuntu 12.04.4
pip install git+https://github.com/hybridlogic/txMySQL.git
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.