Шаг 1. Настройка среды разработки для использования pyodbc в Python Step 1: Configure development environment for pyodbc Python development
Windows Windows
Подключение к Базе данных SQL из Python с помощью pyodbc в ОС Windows. Connect to SQL Database by using Python — pyodbc on Windows:
Скачивание установщика Python. Download Python installer.
Если на вашем компьютере не установлен язык Python, установите его. If your machine does not have Python, install it. Перейдите на страницу загрузки Python и скачайте соответствующий установщик. Go to the Python download page and download the appropriate installer. Например, если вы используете 64-разрядный компьютер, скачайте установщик Python 2.7 или 3.7 (x64). For example, if you are on a 64-bit machine, download the Python 2.7 or 3.7 (x64) installer.
Установите Python. Install Python. Завершив скачивание установщика, выполните следующие шаги. a. Once the installer is downloaded, do the following steps: a. Дважды щелкните файл установщика, чтобы запустить его. Double-click the file to start the installer. b. b. Выберите язык и примите условия. Select your language, and agree to the terms. c. c. Следуйте инструкциям на экране и дождитесь установки Python на компьютере. Follow the instructions on the screen and Python should be installed on your computer. d. d. Чтобы убедиться, что Python установлен, перейдите в папку C:\Python27 или C:\Python37 и запустите python -V или py -V (для версии 3.x). You can verify that Python is installed by going to C:\Python27 or C:\Python37 and run python -V or py -V (for 3.x)
Запустите файл cmd.exe от имени администратора. Open cmd.exe as an administrator
Установите pyodbc с помощью диспетчера пакетов PIP для Python (замените C:\Python27\Scripts путем к папке, где установлен Python). Install pyodbc using pip — Python package manager (Replace C:\Python27\Scripts with your installed Python path)
Linux Linux
Подключение к базе данных SQL из Python с использованием pyodbc: Connect to SQL Database by using Python — pyodbc:
Окно терминала Open terminal
Установка pyodbc Install pyodbc
How to install pyodbc to be used in ipython
I’m confused. I have installed pyodbc on my computer and I was able to import it using other IDE but i’m new to ipython.
I use Ananconda , and was able to install other library using something like
But when I do that with pyodbc using
C:\Users\jeannie.chirayu>pip install pyodbc Downloading/unpacking pyodbc You are installing a potentially insecure and unverifiable file. Future versio ns of pip will default to disallowing insecure files. Downloading pyodbc-3.0.7.zip (85kB): 85kB downloaded Running setup.py egg_info for package pyodbc
Installing collected packages: pyodbc Running setup.py install for pyodbc building ‘pyodbc’ extension C:\Anaconda\Scripts\gcc.bat -DMS_WIN64 -mdll -O -Wall -DPYODBC_VERSION=3.0.7 -IC:\Anaconda\include -IC:\Anaconda\PC -c c:\users\jeanni
1.chi\appdata\local\t emp\pip_build_jeannie.chirayu\pyodbc\src\buffer.cpp -o c:\users\jeanni
1.chi\app data\local\temp\pip_build_jeannie.chirayu\pyodbc\src\buffer.o /Wall /wd4668 /wd4 820 /wd4711 /wd4100 /wd4127 /wd4191 gcc.exe: error: /Wall: No such file or directory gcc.exe: error: /wd4668: No such file or directory gcc.exe: error: /wd4820: No such file or directory gcc.exe: error: /wd4711: No such file or directory gcc.exe: error: /wd4100: No such file or directory gcc.exe: error: /wd4127: No such file or directory gcc.exe: error: /wd4191: No such file or directory error: command ‘gcc’ failed with exit status 1 Complete output from command C:\Anaconda\python.exe -c «import setuptools;__ file__=’c:\users\jeanni
1.chi\appdata\local\temp\pip_build_jeannie.chirayu \pyodbc\setup.py’;exec(compile(open(file).read().replace(‘\r\n’, ‘\n’), __ file__, ‘exec’))» install —record c:\users\jeanni
1.chi\appdata\local\temp\pip- lqnyba-record\install-record.txt —single-version-externally-managed: running install
building ‘pyodbc’ extension
C:\Anaconda\Scripts\gcc.bat -DMS_WIN64 -mdll -O -Wall -DPYODBC_VERSION=3.0.7 -IC :\Anaconda\include -IC:\Anaconda\PC -c c:\users\jeanni
1.chi\appdata\local\temp\ pip_build_jeannie.chirayu\pyodbc\src\buffer.cpp -o c:\users\jeanni
1.chi\appdata \local\temp\pip_build_jeannie.chirayu\pyodbc\src\buffer.o /Wall /wd4668 /wd4820 /wd4711 /wd4100 /wd4127 /wd4191
gcc.exe: error: /Wall: No such file or directory
gcc.exe: error: /wd4668: No such file or directory
gcc.exe: error: /wd4820: No such file or directory
gcc.exe: error: /wd4711: No such file or directory
gcc.exe: error: /wd4100: No such file or directory
gcc.exe: error: /wd4127: No such file or directory
gcc.exe: error: /wd4191: No such file or directory
error: command ‘gcc’ failed with exit status 1
How to install pyodbc with Python 2.7 with Visual Studio 2013?
I’m trying to follow this tutorial: https://pytools.codeplex.com/wikipage?title=PollsDjangoSql but while doing «Configure the project», step 8, I am supposed to install pyodbc using easy_install, but all that happens is:
So I have no idea what is the problem, and as it is extremely generic it is hard to google it. I am using Visual Studio 2013, Python 2.7, Windows 8.1 64bit. Anybody has any idea what is wrong?
1 Answer 1
I spent some time last week trying to install PyODBC for Python 3.4 on a Windows 8.1 machine, and we ended up just using a pre-built wheel ( .whl ) file.
You can install wheel files using pip, so just enter in the location of the .whl file (or the url to the binary) and pip will install it for you. This skips any requirements of having the Visual C++ compiler set up and allows you to stick with just using pip.
I am supposed to install pyodbc using easy_install, but all that happens is: .
You are getting an exit code of 1 because easy_install is failing to build the package. Unfortunately there isn’t an easy way to get the output without manually opening up the command line and running the command yourself. There could be a number of reasons for getting an error code back, such as the wrong package name or a compilation error (most likely) when building non-Python files.
The (sometimes difficult) solution is to fix the vcversal.bat issue for your system (because that’s triggering the compilation issue, usually) and try again. I wasn’t able to get it working correctly alongside of Visual Studio, so you may have better luck just trying through the command line.
The other (sometimes easier) solution if you have a non-Windows system (or a virtual environment) is to build the wheels yourself. As long as you can generate the wheels to work for any system (they end with -any ), they should install smoothly under Windows.