Cannot install pymssql on windows - python

i am trying to install pymssql as
pip install pymssql
i have windows 7 and python 3.5 (from anaconda) but i get
Failed building wheel for pymssql
i believe its related to freetds and python-dev. how do i install these on windows?
Which packages would i need to install? this pip install worked just fine for python 2.7. If the pip does not work,is there any other way i can download and install pymssql?

I just went through this small bit of hell and finally got things working, here is what I ended up doing:
First locate your Python directory (for me it was c:\Python35), then following the instructions found on the PyMSSQL documentation download the FreeTDS binaries and the precompiled OpenSSL binaries. Open SSL binaries are built in different versions of MSVC, for me I needed the MSVC 2015 32-bit binaries (because my copy of Python is the 32-bit build). FreeTDS is a little more cryptic, here the different vs20xx versions work with different generations of Python, in my case -vs2015 worked because I am using Python 3.5 which should work for you as well.
Next extract the dlls from the '/bin' directory in the OpenSSL release and the /lib directory in the FreeTDS release into a folder (in my case I used c:\Python35\FreeTDS).
Finally add this folder to your system PATH. You can now run import pymssql and not receive any errors. On windows you can also create a config file located at C:\freetds.conf which can provide some global settings to keep your python scripts clear of any connection strings.

Related

pip installs wrong platform of pywin32 into Embed Python

I uncompress Embed Python, download pip wheel extract it and put to lib\site-packages. Next run python -m pip install pywin32. So far so god. But when running program it fails to load pywin32file.pyd. With dependency walker I checked and realized it is x86 architecture while running x64 Python. I tried with x64 downloaded version of pywin32 wheel file and got error "Unsupported platform". pip installed x86 wheel but is is not correct.
At the end, I unzipped x64 version of pywin32 wheel into lib\site-packages. Two dlls from pywin32_system32 copied to dll search path and it works now.
We are distributing Embed Python with handful of libraries and pip is god way to get them.
What causes wrong architecture detection by pip and how to solve problem?
The problem you encountered may have had a different cause to my issue, but I was able to resolve a similar problem with pip installing 32-bit packages on 64-bit Python by changing my VSCMD_ARG_TGT_ARCH environment variable from x86 (which seems to be the default setting if you are using the Visual Studio Developer Command Prompt or anything that relies on it) to x86_64.
This seems to be a bug in packaging that was just fixed this April, so, as of this writing, the fix may not have yet made its way into pip.

Package Python project along with dependencies to another machine without internet and different OS

As the title suggests, I have a computer running mac os with a python project. I so have a windows computer without internet, with Python 3.6, and with pip.
The project in question relies on a couple pip package dependencies. Is there anyway to package everything together so that the project can work on the windows machine with no internet?
To some extent pip allows to download a package with dependencies for a different platform. Try
pip download --only-binary=:all: --platform win_amd64 --implementation cp --python-version=3.6 --abi=cp36m 'put-your-package-name-here'
If the package and all its dependencies provide binary wheels pip downloads all of them into the current directory. Move them to the offline computer and run there
pip install --find-links=\path\to\wheels\directory 'your-package'
If the package and all its dependencies provide only source distribution try
pip download --only-binary=:none: --platform win_amd64 --implementation cp --python-version=3.6 --abi=cp36m 'your-package'
But if the package and dependencies are mixed — some have binary wheels and some only sdists — pip fails to download dependencies. There is no solution for this situation. The only workaround is to run Windows on your MacOS — in an emulator or a container.
PS. I use platform win_amd64 as an example. If you have 32-bit Windows or if you have 32-bit Python on a 64-bit Windows — use platform win32.

install mysql-connector in side installation of python (in addition to default python install)

I have a linux CENTOS 6.6 server that has python2.6.6 installed by default.
I need a python version of 2.7 but CENTOS 6.6 NEEDS its default python2.6.6 install present for various system reasons (yum depends on 2.6.6).
As such, I installed python 2.7 in a separate location (/usr/local/lib/python2.7/). Now I am trying to install all the packages that I was using in python2.6.6 in the 2.7 version.
I have mysql-connector library installed in python2.6.6, which was installed using the .rpm file from:
https://dev.mysql.com/doc/connector-python/en/connector-python-installation-binary.html
Installing Connector/Python on Linux Using an RPM Package
Connector/Python Linux RPM packages (.rpm files) are available from the Connector/Python download site (see Section 4.1, “Obtaining Connector/Python”).
To install a Connector/Python RPM package (denoted here as PACKAGE.rpm), use this command:
shell> rpm -i PACKAGE.rpm
To install the C Extension (available as of Connector/Python 2.1.1), install the corresponding package with “cext” in the package name.
RPM provides a feature to verify the integrity and authenticity of packages before installing them. To learn more, see Verifying Package Integrity Using MD5 Checksums or GnuPG.
I'm not sure how I can install the mysql-connector library such that python2.7 recognizes the install.
I noticed that mysql-connector library in the python2.6.6. (default) install is located here:
/usr/lib/python2.6/site-packages/mysql/
/usr/lib/python2.6/site-packages/mysql_connector_python-1.1.5-py2.6.egg-info
Is the solution simply to copy+rename the mysql directory and egg-info file over to /usr/local/lib/python2.7/site-packages/ or are there additional/other steps that I need to follow.
I'm not certain a copy would solve this problem as the mysql directory has __init__.pyc and __init__.pyo files that have paths that are specific to python2.6.6 and likely built during the installation process.
Steps are:
1) re-download the package from `https://dev.mysql.com`
2) untar the `mysql-connector-python-1.1.4.tar.gz`
3) cd into mysql-connector-python-1.1.4
4) envoke `python2.7 setup.py install`
Thats all you need to do.

Installing NumPy and SciPy on 64-bit Windows (with Pip)

I found out that it's impossible to install NumPy/SciPy via installers on Windows 64-bit, that's only possible on 32-bit. Because I need more memory than a 32-bit installation gives me, I need the 64-bit version of everything.
I tried to install everything via Pip and most things worked. But when I came to SciPy, it complained about missing a Fortran compiler. So I installed Fortran via MinGW/MSYS. But you can't install SciPy right away after that, you need to reinstall NumPy. So I tried that, but now it doesn't work anymore via Pip nor via easy_install. Both give these errors:
There are a lot of errors about LNK2019 and LNK1120,.
I get a lot of errors in the range of C: C2065,C2054,C2085,C2143`, etc. They belong together I believe.
There is no Fortran linker found, but I have no idea how to install that, can't find anything on it.
And many more errors which are already out of the visible part of my cmd-windows...
The fatal error is about LNK1120:
build\lib.win-amd64-2.7\numpy\linalg\lapack_lite.pyd : fatal error LNK1120: 7 unresolved externals
error: Setup script exited with error: Command "C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\BLAS /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python27\PCbuild\amd64 /LIBPATH:build\temp.win-amd64-2.7 lapack.lib blas.lib /EXPORT:initlapack_lite build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_litemodule.obj /OUT:build\lib.win-amd64-2.7\numpy\linalg\lapack_lite.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_lite.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_lite.pyd.manifest" failed with exit status 1120
What is the correct way to install the 64-bit versions NumPy and SciPy on a 64-bit Windows machine? Did I miss anything? Do I need to specify something somewhere? There is no information for Windows on these problems that I can find, only for Linux or Mac OS X, but they don't help me as I can't use their commands.
You can install scipy and numpy using their wheels.
First install wheel package if it's already not there...
pip install wheel
Just select the package you want from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
Example: if you're running python3.5 32 bit on Windows choose scipy-0.18.1-cp35-cp35m-win_amd64.whl then it will automatically download.
Then go to the command line and change the directory to the downloads folder and install the above wheel using pip.
Example:
cd C:\Users\[user]\Downloads
pip install scipy-0.18.1-cp35-cp35m-win_amd64.whl
EDIT: The Numpy project now provides pre-compiled packages in the wheel format (package format enabling compiled code as binary in packages), so the installation is now as easy as with other packages.
Numpy (as also some other packages like Scipy, Pandas etc.) includes lot's of C-, Cython, and Fortran code that needs to be compiled properly, before you can use it. This is, btw, also the reason why these Python-packages provide such fast Linear Algebra.
To get precompiled packages for Windows, have a look at Gohlke's Unofficial Windows Binaries or use a distribution like Winpython (just works) or Anaconda (more complex) which provide an entire preconfigured environment with lots of packages from the scientific python stack.
Installing with pip
You can install the numpy and scipy wheels on Windows with pip in one step if you use the appropriate link from Gohlke's Unofficial Windows Binaries (mentioned by sebix) and run the Windows command prompt as Administrator. For example, in Python 3.5, you would simply use something like this:
# numpy-1.9.3+mkl for Python 3.5 on Win AMD64
pip3.5 install http://www.lfd.uci.edu/~gohlke/pythonlibs/xmshzit7/numpy-1.9.3+mkl-cp35-none-win_amd64.whl
# scipy-0.16.1 for Python 3.5 on Win AMD64
pip3.5 install http://www.lfd.uci.edu/~gohlke/pythonlibs/xmshzit7/scipy-0.16.1-cp35-none-win_amd64.whl
Best solution for this is to download and install VCforPython2.7 from https://www.microsoft.com/en-us/download/details.aspx?id=44266
Then try pip install numpy
Downloading the binaries for 64-bit from http://www.lfd.uci.edu/~gohlke/pythonlibs/, and installing it directly with pip in this order:
pip install numpy-1.12.0+mkl-cp36-cp36m-win64.whl
pip install scipy-0.18.1-cp36-cp36m-win64.whl
pip install matplotlib-2.0.0-cp36-cp36m-win64.whl
Note that you must place command prompt in the folder where you put the .whl files after downloading them, and you must run it as administrator,
worked for me on Windows 10 64-bit now python is up and running.
You can now pip install numpy on Windows!
"Note: this page has only historical relevance, you can now pip-install for windows"
Source: https://github.com/numpy/numpy/wiki/Whats-with-Windows-builds
Intel provides pre-compiled Python modules for free in their "Intel Distribution for Python". The modules are compiled against Intel's MKL (Math Kernel Library) and thus optimized for faster performance. The package includes NumPy, SciPy, scikit-learn, pandas, matplotlib, Numba, tbb, pyDAAL, Jupyter, and others. Find more information and the download link here
If you are on windows , you wouldn't need wheel anyway! You can directly install package by downloading the 32-bit package as win32 from this link [http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy] and then move that downloaded package to cmd's current directory and open cmd and write following codepip install numpy-1.13.1+mkl-cp36-cp36m-win32.whl then do it same for scipy
For 64-bit you need to install mingw-w64 as it is gcc and compiles numpy and scipy as precompiled status.
Currently it works fine with 32-bit.So I had opted for win32 package both for numpy+mkl and scipy in that link.
Hope This works! Give a try
You can download the needed packages from here and use pip install "Abc.whl" from the directory where you have downloaded the file.
Look into python wheels to solve your problem. The best part of python wheels is that they let you install C extensions with no compilers. I just installed numpy and scipy using pip in a clean python install and they both worked fine.
for python 3.6, the following worked for me
launch cmd.exe as administrator
pip install numpy-1.13.0+mkl-cp36-cp36m-win32
pip install scipy-0.19.1-cp36-cp36m-win32
Package version are very important.
I found some stable combination that works on my Windows10 64 bit machine:
pip install numpy-1.12.0+mkl-cp36-cp36m-win64.whl
pip install scipy-0.18.1-cp36-cp36m-win64.whl
pip install matplotlib-2.0.0-cp36-cp36m-win64.whl
Source.
Hey I had the same issue.
You can find all the packages in the link below:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn
And choose the package you need for your version of windows and python.
You have to download the file with whl extension. After that, you will copy the file into your python directory then run the following command:
py -3.6 -m pip install matplotlib-2.1.0-cp36-cp36m-win_amd64.whl
Here is an example when I wanted to install matplolib for my python 3.6 https://www.youtube.com/watch?v=MzV4N4XUvYc
and this is the video I followed.
Follow these steps:
Open CMD as administrator
Enter this command : cd..
cd..
cd Program Files\Python38\Scripts
Download the package you want and put it in Python38\Scripts folder.
pip install packagename.whl
Done
You can write your python version instead of "38"

How do I upgrade the SQLite version used by Python's SQLite3 module on Mac?

I would like to use the SQLite version 3.8 with Python, but the SQLite3 module is using an out of date version. I've installed SQLite version 3.8.4.3 on my Mac, but sqlite3.sqlite_version still returns 3.7.13.
I've done quite a bit of searching on SO and elsewhere, but can't seem to find a definitive answer.
Thanks!
From your comments, your problem is that your pre-installed sqlite 3.7 comes higher on your path than your third-party 3.8. This means that when you build pysqlite2, by default, it will find and use that 3.7, so it's not doing you any good. And you probably don't want to change around your whole path just to deal with this.
But that's fine, as long as the 3.8 is found first at build time, it doesn't matter what comes first at runtime; the path to 3.8 will be baked into the module. There are a number of ways to do this, but the simplest is something like this:
$ brew install sqlite3
$ sudo -s
# LDFLAGS=-L/usr/local/opt/sqlite/lib CPPFLAGS=-I/usr/local/opt/sqlite/include pip2.7 install pysqlite
# ^D
$ python
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.7.13'
>>> import pysqlite2.dbapi2
>>> pysqlite2.dbapi2.sqlite_version
'3.8.6'
The LDFLAGS and CPPFLAGS variables came from the output of the brew install sqlite3 step. If you've installed sqlite3 in some other way, you'll need to get the appropriate values—possibly /usr/local/lib and /usr/local/include, but if not, search for libsqlite3.dylib and sqlite3.h.
Note that if you follow exactly these steps, you'll get a non-fat version of libsqlite3, meaning that pysqlite2 won't work in 32-bit mode. I doubt that's an issue for you, but if it is, you can just install it --universal, or use a different installer instead of Homebrew.
If you use Anaconda as your package manager, run conda install -c anaconda sqlite.
Run python -c "import sqlite3; print(sqlite3.sqlite_version)" to confirm that you have the latest version.
Source
I think the easiest way is to update your Python to the latest version because sqlite3 is shipped with Python.
Otherwise have to update the pysqlite package as well. Under Linux there is a precompiled package python-sqlite.
You can do that by using easy_install. For building this package you need some packages. Nessecerily build pysqlite with the new installed version of sqlite3, in your case 3.8.4.3.
sudo easy_install pysqlite
or
sudo pip install --upgrade pysqlite
This works for me on Windows.
Download the latest pre-compiled binary files for Sqlite3
https://www.sqlite.org/download.html
Find the DLL library sqlite3.dll
Find the Python library folder, where Python sqlite3.dll is stored
Backup Python sqlite3.dll and replace it with the latest sqlite3.dll

Categories