pyodbc icon indicating copy to clipboard operation
pyodbc copied to clipboard

pip install pyodbc fails on Windows

Open kirilan opened this issue 11 years ago • 29 comments

this fails consistently on 2 different machines one Windows Server 2012R2 and one Win8.1 the error is the same.

C:\Windows\System32>pip install pyodbc Collecting pyodbc Using cached pyodbc-3.0.10.tar.gz Installing collected packages: pyodbc Running setup.py install for pyodbc Complete output from command "c:\program files (x86)\python 3.5\python.exe" -c "import setuptools, tokenize;file='C:\Users\Kiril\AppData\Local\Temp \pip-build-wx_guj66\pyodbc\setup.py';exec(compile(getattr(tokenize, 'open', o pen)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --recor d C:\Users\Kiril\AppData\Local\Temp\pip-0hu94gdr-record\install-record.txt --sin gle-version-externally-managed --compile: running install running build running build_ext building 'pyodbc' extension error: [WinError 2] The system cannot find the file specified

----------------------------------------

Command ""c:\program files (x86)\python 3.5\python.exe" -c "import setuptools, t okenize;file='C:\Users\Kiril\AppData\Local\Temp\pip-build-wx_guj66\py odbc\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().re place('\r\n', '\n'), file, 'exec'))" install --record C:\Users\Kiril\AppData \Local\Temp\pip-0hu94gdr-record\install-record.txt --single-version-externally-m anaged --compile" failed with error code 1 in C:\Users\Kiril\AppData\Local\Temp
pip-build-wx_guj66\pyodbc

C:\Windows\System32>

kirilan avatar Sep 18 '15 21:09 kirilan

I am having the same issue.

reading manifest file 'pyodbc.egg-info\SOURCES.txt' Traceback (most recent call last): File "", line 1, in File "C:\Users\SDESHP~2\AppData\Local\Temp\pip-build-3mtp8ff8\pyodbc\setup.py", line 311, in main() File "C:\Users\SDESHP~2\AppData\Local\Temp\pip-build-3mtp8ff8\pyodbc\setup.py", line 113, in main setup(**kwargs) File "c:\python 3.5\lib\distutils\core.py", line 148, in setup dist.run_commands() File "c:\python 3.5\lib\distutils\dist.py", line 955, in run_commands self.run_command(cmd) File "c:\python 3.5\lib\distutils\dist.py", line 974, in run_command cmd_obj.run() File "c:\python 3.5\lib\site-packages\setuptools\command\install.py", line 61, in run return orig.install.run(self) File "c:\python 3.5\lib\distutils\command\install.py", line 551, in run self.run_command(cmd_name) File "c:\python 3.5\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "c:\python 3.5\lib\distutils\dist.py", line 974, in run_command cmd_obj.run() File "c:\python 3.5\lib\site-packages\setuptools\command\install_egg_info.py", line 33, in run self.run_command('egg_info') File "c:\python 3.5\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "c:\python 3.5\lib\distutils\dist.py", line 974, in run_command cmd_obj.run() File "c:\python 3.5\lib\site-packages\setuptools\command\egg_info.py", line 180, in run self.find_sources() File "c:\python 3.5\lib\site-packages\setuptools\command\egg_info.py", line 207, in find_sources mm.run() File "c:\python 3.5\lib\site-packages\setuptools\command\egg_info.py", line 291, in run self.add_defaults() File "c:\python 3.5\lib\site-packages\setuptools\command\egg_info.py", line 327, in add_defaults self.read_manifest() File "c:\python 3.5\lib\site-packages\setuptools\command\sdist.py", line 196, in read_manifest self.filelist.append(line) File "c:\python 3.5\lib\site-packages\setuptools\command\egg_info.py", line 232, in append path = convert_path(item) File "c:\python 3.5\lib\distutils\util.py", line 125, in convert_path raise ValueError("path '%s' cannot be absolute" % pathname) ValueError: path '/Users/mkleehammer/dev/pyodbc/src/buffer.cpp' cannot be absolute

----------------------------------------

Command ""c:\python 3.5\python.exe" -c "import setuptools, tokenize;file='C:\Users\SDESHP~2\AppData\Local\Temp\pip-build-3mtp8ff8\pyodbc\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record C:\Users\SDESHP~2\AppData\Local\Temp\pip-cvlyp954-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\SDESHP~2\AppData\Local\Temp\pip-build-3mtp8ff8\pyodbc

sdeshpande avatar Sep 29 '15 19:09 sdeshpande

It looks like you're both using Python 3.5. Does this also happen with older Python versions?

brousch avatar Oct 09 '15 19:10 brousch

I experienced the issue only with Python 3.5

sdeshpande avatar Oct 14 '15 17:10 sdeshpande

I am on Windows Python 3.5, and I get the same issue

  File "c:\users\dvarghes\appdata\local\programs\python\python35\lib\site-packages\setuptools\command\egg_info.py", line 232, in append
    path = convert_path(item)
  File "c:\users\dvarghes\appdata\local\programs\python\python35\lib\distutils\util.py", line 125, in convert_path
    raise ValueError("path '%s' cannot be absolute" % pathname)
ValueError: path '/Users/mkleehammer/dev/pyodbc/src/buffer.cpp' cannot be absolute

----------------------------------------

Command "c:\users\dvarghes\appdata\local\programs\python\python35\python.exe -c "import setuptools, tokenize;file='C:\Users\dvarghes\AppData\Local\Temp\pip-build-uk7rkkwm\pyodbc\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record C:\Users\dvarghes\AppData\Local\Temp\pip-bzombnw1-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\dvarghes\AppData\Local\Temp\pip-build-uk7rkkwm\pyodbc

dvarghes avatar Oct 15 '15 07:10 dvarghes

Same problem here. C:\Users\user\AppData\Local\Programs\Python\Python35>cd Scripts

C:\Users\user\AppData\Local\Programs\Python\Python35\Scripts>pip install pyodbc Collecting pyodbc Using cached pyodbc-3.0.10.tar.gz Installing collected packages: pyodbc Running setup.py install for pyodbc Complete output from command c:\users\user\appdata\local\programs\python\pyt hon35\python.exe -c "import setuptools, tokenize;file='C:\Users\user\AppD ata\Local\Temp\pip-build-sg8od2fp\pyodbc\setup.py';exec(compile(getattr(tok enize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record C:\Users\user\AppData\Local\Temp\pip-07nqf11x-record\install-r ecord.txt --single-version-externally-managed --compile: running install running build running build_ext building 'pyodbc' extension error: [WinError 2] The system cannot find the file specified

----------------------------------------

Command "c:\users\user\appdata\local\programs\python\python35\python.exe -c "imp ort setuptools, tokenize;file='C:\Users\user\AppData\Local\Temp\pip-bu ild-sg8od2fp\pyodbc\setup.py';exec(compile(getattr(tokenize, 'open', open)(f ile).read().replace('\r\n', '\n'), file, 'exec'))" install --record C:\Use rs\user\AppData\Local\Temp\pip-07nqf11x-record\install-record.txt --single-versi on-externally-managed --compile" failed with error code 1 in C:\Users\user\AppDa ta\Local\Temp\pip-build-sg8od2fp\pyodbc

jrandrews avatar Oct 19 '15 23:10 jrandrews

There is no wheel (binary distribution) for 3.5 on PyPI. So while they are not provided you can use unofficial binaries from here. Just download the matching file for Python 3.5 and install it with pip install pyodbc-3.0.10-cp35-none-win32.whl.

schlamar avatar Oct 31 '15 05:10 schlamar

Thanks schlamar. That worked nicely.

joshmorel avatar Nov 06 '15 21:11 joshmorel

Also thank you, I searched for hours for an answer on this!

JohnBuckleyGitHub avatar Nov 09 '15 03:11 JohnBuckleyGitHub

Thanks this solved my problem too! "Once more into the breech" solving problems one at a time, together!

tamboer avatar Dec 07 '15 12:12 tamboer

schlamar the world needs more people like you :)

stubbd01 avatar Feb 12 '16 17:02 stubbd01

Hi,

This also happen on Python 2.6

Regards.

bhbosman avatar Mar 09 '16 15:03 bhbosman

@mkleehammer I love pyodbc. Is there any way you could put a wheel for Python 3.5 up on PyPI?

This would make it much easier to build upon!

levithatcher avatar Oct 30 '16 17:10 levithatcher

I too would appreciate a whl for this on pypi

LegoStormtroopr avatar Nov 27 '16 08:11 LegoStormtroopr

This is one of the first things to appear when googling the error message about buffer.cpp cannot be absolute with pyodbc.

If you download the source .tar.gz file from pypi, open pyodbc.egg-info\SOURCES.txt and remove the series of lines at the top of the file that begin with /User/mkleehammer/.... and then run python setup.py build followed by python setup.py install it should work.

I don't know why those files are listed, if you look at the end file paths they match files already listed a bit more down in the SOURCES.txt file.

iarp avatar Jan 06 '17 15:01 iarp

@schlamar I installed pyodbc for my python 3.6. But when I am not able to use that in my code. It says, "the definition was found at C:\pyodbc.pyd.. (which can't be opened because it is a compiled extension)". Please help

PythonNovice5 avatar Feb 15 '17 13:02 PythonNovice5

@PythonNovice5 How did you install pyodbc? I am now providing binary wheels for Windows and macOS for most versions of Python.

If you did not use pip, please try again with: pip install pyodbc

(If you ever need to upgrade pyodbc but it is already installed, use: pip install --upgrade pyodbc)

mkleehammer avatar Feb 15 '17 15:02 mkleehammer

@mkleehammer I installed it using "python -m pip install pyodbc" command as "pip install -U pyodbc" (-U to install upgraded version) gives 'fatal launch error' for python 3.6. The error I got for compiled extension is gone now, as I had to install few other libraries (Bx4, python-form etc) in my python framework and after that the error was gone. Though I still don't understand why it was showing error before and how come python framework is taking compiled file (pyodbc.pyd in site-packages) for usage.

Thanks for the wheels anyway, it was a great relief after searching for the solution for hours.

PythonNovice5 avatar Feb 16 '17 05:02 PythonNovice5

Note for users of tox who come here!!

This error will occur if you try to run PyODBC under tox on Windows, and its because tox is actually suppressing the WINDIR environment variable. You can just pass that variable through and this error will go away.

I did a brief write up on that here: www.kidstrythisathome.com/2017/02/tox-pyodbc-and-appveyor.html

LegoStormtroopr avatar Feb 16 '17 05:02 LegoStormtroopr

@LegoStormtroopr Wow - I did not know that. Thanks. We should get that on the Wiki somewhere.

Just to clarify - pyodbc itself isn't looking for any environment variables. I would bet that the driver was installed with those in the odbcinst.ini.

mkleehammer avatar Feb 16 '17 15:02 mkleehammer

Not quite sure if this is related, but when I ran: python setup.py install (with python 3.5, windows 7, and visual studio 2015) I got the following error: pyodbc-4.0.13\src\pyodbc.h(19): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory After looking at https://github.com/openssl/openssl/issues/586 I installed windows 8.1 SDK and the install was successful.

jrasm91 avatar Apr 04 '17 20:04 jrasm91