Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip install pyodbc fails on Windows #77

Closed
kirilan opened this issue Sep 18, 2015 · 29 comments
Closed

pip install pyodbc fails on Windows #77

kirilan opened this issue Sep 18, 2015 · 29 comments

Comments

@kirilan
Copy link

kirilan commented Sep 18, 2015

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>

@sdeshpande
Copy link

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\SDESHP2\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\SDESHP2\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\SDESHP2\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

@brousch
Copy link

brousch commented Oct 9, 2015

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

@sdeshpande
Copy link

I experienced the issue only with Python 3.5

@dvarghes
Copy link

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

@jrandrews
Copy link

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

@schlamar
Copy link

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.

@joshmorel
Copy link

Thanks schlamar. That worked nicely.

@JohnBuckleyGitHub
Copy link

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

@tamboer
Copy link

tamboer commented Dec 7, 2015

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

@stubbd01
Copy link

schlamar the world needs more people like you :)

@bhbosman
Copy link

bhbosman commented Mar 9, 2016

Hi,

This also happen on Python 2.6

Regards.

@levithatcher
Copy link

@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!

@LegoStormtroopr
Copy link

I too would appreciate a whl for this on pypi

@iarp
Copy link

iarp commented Jan 6, 2017

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.

@PythonNovice5
Copy link

PythonNovice5 commented Feb 15, 2017

@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

@mkleehammer
Copy link
Owner

@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)

@PythonNovice5
Copy link

@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.

@LegoStormtroopr
Copy link

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

@mkleehammer
Copy link
Owner

@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.

@jrasm91
Copy link

jrasm91 commented Apr 4, 2017

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 openssl/openssl#586 I installed windows 8.1 SDK and the install was successful.

@mkleehammer
Copy link
Owner

mkleehammer commented Apr 28, 2017

@jrasm91

The error is because something was trying to build pyodbc instead of downloading a prebuilt binary for Windows. If you are trying to build it from source, then you need to make sure you have everything configured for development. The Building pyodbc from source page should be up to date, but feel free to update it.

However, if you are just looking to use pyodbc, you can install a pre-built binary using pip:

pip install pyodbc

There are pre-built binaries for most Python versions, both 32-bit and 64-bit, for Windows. There are also macOS builds.

@Ahmad-DM
Copy link

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.

Hi,
I have the same problem as everyone on odbc and this looks like the solution I need. I dowloaded the wheel file I need for my Python (3.9.6). Tried to install it on terminal with teh syntax you provided but it gave me the below error message. Can you please give more instructions? I'm not sure where I should download the wheel file.

WARNING: Requirement 'pyodbc-4.0.32-cp39-cp39-win_amd64.whl' looks like a filename, but the file does not exist
ERROR: pyodbc-4.0.32-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.

@Rahulnitt1
Copy link

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.

Hi, I have the same problem as everyone on odbc and this looks like the solution I need. I dowloaded the wheel file I need for my Python (3.9.6). Tried to install it on terminal with teh syntax you provided but it gave me the below error message. Can you please give more instructions? I'm not sure where I should download the wheel file.

WARNING: Requirement 'pyodbc-4.0.32-cp39-cp39-win_amd64.whl' looks like a filename, but the file does not exist ERROR: pyodbc-4.0.32-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.

place the wheel file where python was installed and environment variable set to , then open cmd and go to that path and run pip install filename , it will work as it worked for me

@Rahulnitt1
Copy link

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.

you are superb man it solved my problem as well !!! kudos pal

@marmikreal
Copy link

With latest Python version 3.11.0

Fails with following command:
pip install pyodbc --use-pep517

Collecting pyodbc
Using cached pyodbc-4.0.34.tar.gz (271 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyodbc
Building wheel for pyodbc (pyproject.toml) ... error
error: subprocess-exited-with-error

Building wheel for pyodbc (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
running bdist_wheel
running build
running build_ext
building 'pyodbc' extension
creating build
creating build\temp.win-amd64-cpython-311
creating build\temp.win-amd64-cpython-311\Release\src
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DPYODBC_VERSION=4.0.34 -IC:\Users<user name >\AppData\L-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /EHsc /Tpsrc\buffer.cpp /Fobuild\temp.win-amd64-cpython-311\Release\src\buffer.obj /Wall /wd4514 /wd4820 /wd4668 /wd4711 /wd4100 /wd4127 /wd4191 /d2FH4-
ory
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyodbc
Failed to build pyodbc
ERROR: Could not build wheels for pyodbc, which is required to install pyproject.toml-based projects

@marmikreal
Copy link

Tried installing .whl manually from location. https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyodbc
that also fails with error. (both 32 bit and 64 bit.)

PS D:\Py> pip install pyodbc-4.0.32-cp310-cp310-win_amd64.whl
ERROR: pyodbc-4.0.32-cp310-cp310-win_amd64.whl is not a supported wheel on this platform.
PS D:\Py> pip install pyodbc-4.0.32-cp310-cp310-win32.whl
ERROR: pyodbc-4.0.32-cp310-cp310-win32.whl is not a supported wheel on this platform.

So I guess I need to wait for cp311?

@leonkosak
Copy link

I have the same exceptions.
Probably waiting for cp311 is necessary.

@KianaBagheri
Copy link

I have same problem too!
What should I do?

@keitherskine
Copy link
Collaborator

pyodbc 4.0,35 has just been released on PyPi, including Windows wheels for Python 3.11. Please try installing pyodbc again in the usual manner pip install pyodbc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests