How to install pymssql module in Python 3.6? - python-3.x

I have been through a couple of documentations involving FreeTDS, Wheel, git and github but nothing was working on my Windows 10 PC with Python 3.6 but I need to install it. I'm working on a project and I'm most comfortable with mssql which is already installed in my pc.

this seems to work from
export PYMSSQL_BUILD_WITH_BUNDLED_FREETDS=1
pip install pymssql

Remember to install FreeTDS first.
Ubuntu/Debian:
sudo apt-get install freetds-dev
Mac OS X with Homebrew:
brew install freetds
Finally:
pip install pymssql

As the site pymssql_documentation page states that the module is deprecated,
we can use pip install "pymssql<3.0". It works on python 3.0 and above.
I think they should change it in the main copy area as well. as of 12/17/2019 it is still showing pip install pymssql, which has been updated on Nov 16 2019.

Just use the newest build of pymssql from gitub:
pip3 install git+https://github.com/pymssql/pymssql
Also works for python2
pip install git+https://github.com/pymssql/pymssql
UPDATE:
For macOS Big Sur Apple M1 chip processor:
You will need to install Rosetta2 emulator for the new ARM silicon (M1 chip). I just installed Rosetta2 via terminal using:
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
Homebrew for ARM M1 chip:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Homebrew for M1 ARM command to install packages: arch -x86_64 brew install <package>. It is necessary to install FreeTDS before installing the pymssql.
arch -x86_64 brew install freetds
Finally:
pip install pymssql
output:
Collecting pymssql
Using cached pymssql-2.1.5.tar.gz (167 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing wheel metadata ... done
Building wheels for collected packages: pymssql
Building wheel for pymssql (PEP 517) ... done
Created wheel for pymssql: filename=pymssql-2.1.5-cp39-cp39-macosx_10_9_x86_64.whl size=287029
.
.
.
Successfully built pymssql
Installing collected packages: pymssql
Successfully installed pymssql-2.1.5

Related

Error installing psycopg2 on macOS with building wheel [duplicate]

I'm attempting to make a website with a few others for the first time, and have run into a weird error when trying to use Django/Python/VirtualEnv. I've found solutions to this problem for other operating systems, such as Ubuntu, but can't find any good solutions for Mac.
This is the relevant code being run:
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
After running that block, I get the following errors:
AssertionError
Failed building wheel for django-toolbelt
Running setup.py bdist_wheel for psycopg2
...
AssertionError
Failed building wheel for psycopg2
Failed to build django-toolbelt psycopg2
I believe I've installed the "django-toolbelt" and "psycopg2", so I'm not sure why it would be failing.
The only difference I can think of is that I did not use the command
sudo apt-get install libpq-dev
as was instructed for Ubuntu usage as I believe that installing postgresql with brew took care of the header.
Thanks for any help or insight!
For MacOS users
After trying all the above methods (which did not work for me on MacOS 10.14), that one worked :
Install openssl with brew install openssl if you don't have it already.
add openssl path to LIBRARY_PATH :
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
install psycopg2 with pip pip3 install psycopg2
I had the same problem on Arch linux. I think that it's not an OS dependant problem. Anyway, I fixed this by finding the outdated packages and updating then.
pip uninstall psycopg2
pip list --outdated
pip install --upgrade wheel
pip install --upgrade setuptools
pip install psycopg2
I was also getting same error.
Using Python 3.7.3 and pip 19.1.1.
I used following command.
pip install psycopg2-binary==2.8.3
TDLR
If you aren't used to installing Python C-extensions, and psycopg2 isn't a core part of your work, try
pip install psycopg2-binary
Building Locally
psycopg2 is a C-extension, so it requires compilation when being installed by pip. The Build Prerequisites section of the docs explain what must be done to make installation via pip possible. In summary (for psycopg 2.8.5):
a C compiler must be installed on the machine
the Python header files must be installed
the libpq header files must be installed
the pg_config program must be installed (it usually comes with the libpq headers) and on $PATH.
With these prerequisites satisfied, pip install psycopg2 ought to succeed.
Installing pre-compiled wheels
Alternatively, pip can install pre-compiled binaries so that compilation (and the associated setup) is not required. They can be installed like this:
pip install psycopg2-binary
The docs note that
The psycopg2-binary package is meant for beginners to start playing with Python and PostgreSQL without the need to meet the build requirements.
but I would suggest that psycopg2-binary is often good enough for local development work if you are not using psycopg2 directly, but just as a dependency.
Concluding advice
Read the informative installation documentation, not only to overcome installation issues but also to understand the impact of using the pre-compiled binaries in some scenarios.
I had same problem and this appears to be a Mojave Issue, I was able to resolve with:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
For Mac OS X users:
1. First check your postgresql path by running this command in terminal:
pg_config
If this fails lookup how to add pg_config to your path.
2. Next install Xcode Tools by running this command in terminal:
xcode-select --install
If you have both those sorted out now try to install psycopg2 again
For MacOS users, this question has the correct solution:
install command line tools if necessary:
xcode-select --install
then
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2
I was also facing the same after running all the above commands, but the following two commands worked for me:
Instead of pip, use this:
sudo apt-get install libpq-dev
then run this command:
pip install psycopg2
On OS X, I was able to solve this by simply upgrading wheel before installing psycopg2:
pip install --upgrade wheel
For OSX Sierra users, it seems that an xcode update is the solution: Can't install psycopg2 package through pip install... Is this because of Sierra?
I tried all the above solutions but they did not work for me. What I did was change the psycopg2 version in my requirements.txt file from psycopg2==2.7.4 to psycopg2==2.7.6
Is your error message complete? the most encountered reason for failing to install psycopg2 on mac from pip is pg_config is not in path.
by the way, using macports or fink to install psycopg2 is more recommended way, so you don't have to worry about pg_config, libpq-dev and python-dev.
plus, are using Python 3.5? then upgrage your wheel to > 0.25.0 using pip.
I faced the same issue, but the answers above didn't work for me.
So this is what I did in my requirements.txt
psycopg2-binary==2.7.6.1 and it worked fine
I had this issue on several packages, including psycopg2, numpy, and pandas. I simply removed the version from the requirements.txt file, and it worked.
So instead of psycopg2-binary==2.7.6.1 I just had psycopg2-binary.
I know you are asking for development environment but if you are deploying on server say, Heroku. Just add below line in the requirements.txt of your project.
django-heroku==0.3.1
As this package itself will install the required packages like psycopg2 on server deployment.So let the server(heroku) should take care of it.
sudo apt install libpq-dev python3.X-dev
where X is the sub version,
these should be followed by :
pip install --upgrade wheel
pip install --upgrade setuptools
pip install psycopg2
Enjoy !!!
I solved my problem by updating/installing vs_BuildTools. The link to the software was given in the error itself.
Error Image
Fixed by installing python3.7-dev: sudo apt install python3.7-dev, based on the link.
Python: 3.7
Ubuntu: 20.04.3 LTS

Trying to download homebrew

I'm trying to install brew
Windows 10 cmd
> pip install brew
Downloading https://files.pythonhosted.org/packages/93/c3/3534ff8c715a34ba11a8419bb62f4ea71797b6eb314dd786d6035bcb2592/homebrew-0.1.10-py3-none-any.whl
Installing collected packages: homebrew
Successfully installed homebrew-0.1.10
> brew install PyAudio
"brew" is not an internal or external command or executable

Can't install pymssql on Manjaro - compilation issues?

I want to install pymssql in my virtual env (Python 3) in order to use it in Django app. My OS is Manjaro, I have already installed FreeTDS (and configure freetds file accordingly to Arch Wiki) and msodbcsql. However, I still can't install pymssql and here's error traceback: https://gist.github.com/szpone/0e494c388e5a105ed274da8c97b3e945
So apparently all I had to do is download the latest version of pymssql directly from git - pip install git+https://github.com/pymssql/pymssql.git. I tried this earlier, but for some reason, pip couldn't finish installation.

Issue installing shapely Python Package

I am running python 3.6 on windows and am attempting to install Shapely using
pip install shapely==1.6b2
It is giving me the following errors
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Cameron\AppData\Local\Temp\pip-build-242ae_ih\shapely\
I have seen the other posts about this issue and have tried:
pip install --upgrade setuptools
pip install ez_setup
easy_install -U setuptools
Nothing seems to work and I am not sure what to do next. Any advice would be appreciated.
Thanks
You may try to use the binary from this unofficial site. Just use pip install {wheel file name} to install it.
Shapely‑1.5.17‑cp36‑cp36m‑win32.whl (32-bit)
Shapely‑1.5.17‑cp36‑cp36m‑win_amd64.whl (64-bit)
Hope this would make the installation easier.
I had a similar error for installing shapely-1.5.17 via pip install shapely, and installing this made the pip install command work thereafter:
sudo apt-get install libgeos-dev
As of 2020, you can now simply install Shapely for Windows with:
pip install shapely
(you many need --upgrade to get at least version 1.7.0, when binary wheels were added for Windows)

Installing NumPy on Fedora 24 with pip

My question is perhaps similar to Installing Numpy on Fedora 19 with pip.
I would like to install NumPy with pip on (a freshly installed) Fedora 24.
Fedora already has pip (via the command pip3). When I write pip3 install numpy, pip downloads a zip (with the source code inside) and tries to compile (build a local wheel). But I do not have Python headers so it can't compile. I guess that if I install python3-devel pip will manage to compile NumPy as I already have GCC (but no linear algebra library).
But what I want to do is to install NumPy from a wheel only. Normally if a wheel is available on PyPI, then pip will download the corresponding wheel file. It is so on other distributions: Arch, Ubuntu. I installed the package python3-wheel also, but it didn't have any effect.
Can somebody make the situation clearer?
You need to upgrade your pip.
I've just tried to install numpy on fresh fedora container and pip tried to download sources and compile them, and failed because of python3-devel missing.
But I updated pip with pip3 install --upgrade pip and afterwards pip3 install numpy downloaded numpy-1.11.1-cp35-cp35m-manylinux1_x86_64.whl file and isnstaled it without issues.

Resources