mkleehammer / pyodbc

Python ODBC bridge
https://github.com/mkleehammer/pyodbc/wiki
MIT No Attribution
2.92k stars 563 forks source link

Issues with pyodbc installation in venv python 3.10 #1020

Closed myamullaciencia closed 2 years ago

myamullaciencia commented 2 years ago

I have these environment and i would like to install pyodbc to work with accdb and mdb files.

I have created a virtual environment venv where i 'm trying to install the pyodbc as

python -m pip install pyodbc

Here it gives an error as:

Collecting pyodbc
  Using cached pyodbc-4.0.32.tar.gz (280 kB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for pyodbc, since package 'wheel' is not installed.
Installing collected packages: pyodbc
  Running setup.py install for pyodbc ... error
  error: subprocess-exited-with-error

  × Running setup.py install for pyodbc did not run successfully.
  │ exit code: 1
  ╰─> [5 lines of output]
      running install
      running build
      running build_ext
      building 'pyodbc' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pyodbc

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

I have verified that MS Visual C++ is already installed and but it is still giving an error.

could you please help me out to solve this on priority ?

gordthompson commented 2 years ago

Duplicate of #981

myamullaciencia commented 2 years ago

Are these unofficial wheels as a workaround (https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyodbc)) safer ? any other work around ? and when can we expect this to be support python 3.10?

myamullaciencia commented 2 years ago

if my python downgrades to 3.7 would this be worked out ?

gordthompson commented 2 years ago

if my python downgrades to 3.7 would this be worked out ?

Yes, there are Windows wheels for Python 3.7 on PyPI.

Bhavya-official commented 2 years ago

I hope this may help you https://stackoverflow.com/questions/71295840/python-pip-error-legacy-install-failure

khaihc commented 2 years ago

I downgraded python to 3.7. I ran the command python application.py and still error ModuleNotFoundError: No module named 'pyodbc'. How can I fix it? This is my error <<
(venv) testadmin@linux-vm-west2:~/testadmin$ python application.py

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/testadmin/venv/lib/python3.8/site-packages/flask/app.py", line 2095, in call return self.wsgi_app(environ, start_response) File "/home/testadmin/venv/lib/python3.8/site-packages/flask/app.py", line 2080, in wsgi_app response = self.handle_exception(e) File "/home/testadmin/venv/lib/python3.8/site-packages/flask/app.py", line 2077, in wsgi_app response = self.full_dispatch_request() File "/home/testadmin/venv/lib/python3.8/site-packages/flask/app.py", line 1525, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/testadmin/venv/lib/python3.8/site-packages/flask/app.py", line 1523, in full_dispatch_request rv = self.dispatch_request() File "/home/testadmin/venv/lib/python3.8/site-packages/flask/app.py", line 1509, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(req.view_args) File "/home/testadmin/FlaskExercise/views.py", line 12, in home animals = models.Animal.query.all() File "/home/testadmin/venv/lib/python3.8/site-packages/flask_sqlalchemy/init.py", line 552, in get return type.query_class(mapper, session=self.sa.session()) File "/home/testadmin/venv/lib/python3.8/site-packages/sqlalchemy/orm/scoping.py", line 47, in call sess = self.registry() File "/home/testadmin/venv/lib/python3.8/site-packages/sqlalchemy/util/collections.py", line 1010, in call return self.registry.setdefault(key, self.createfunc()) File "/home/testadmin/venv/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 4205, in call return self.class(local_kw) File "/home/testadmin/venv/lib/python3.8/site-packages/flask_sqlalchemy/init.py", line 176, in init bind = options.pop('bind', None) or db.engine File "/home/testadmin/venv/lib/python3.8/site-packages/flask_sqlalchemy/init.py", line 998, in engine return self.get_engine() File "/home/testadmin/venv/lib/python3.8/site-packages/flask_sqlalchemy/init.py", line 1017, in get_engine return connector.get_engine() File "/home/testadmin/venv/lib/python3.8/site-packages/flask_sqlalchemy/init.py", line 594, in get_engine self._engine = rv = self._sa.create_engine(sa_url, options) File "/home/testadmin/venv/lib/python3.8/site-packages/flask_sqlalchemy/init.py", line 1027, in create_engine return sqlalchemy.create_engine(sa_url, *engine_opts) File "", line 2, in create_engine File "/home/testadmin/venv/lib/python3.8/site-packages/sqlalchemy/util/deprecations.py", line 309, in warned return fn(args, kwargs) File "/home/testadmin/venv/lib/python3.8/site-packages/sqlalchemy/engine/create.py", line 560, in create_engine dbapi = dialect_cls.dbapi(dbapi_args) File "/home/testadmin/venv/lib/python3.8/site-packages/sqlalchemy/connectors/pyodbc.py", line 43, in dbapi return import("pyodbc") ModuleNotFoundError: No module named 'pyodbc' 127.0.0.1 - - [02/Apr/2022 13:59:31] "GET /?debugger=yes&cmd=resource&f=style.css HTTP/1.1" 304 - 127.0.0.1 - - [02/Apr/2022 13:59:31] "GET /?debugger=yes&cmd=resource&f=debugger.js HTTP/1.1" 304 - 127.0.0.1 - - [02/Apr/2022 13:59:32] "GET /?debugger=yes&cmd=resource&f=console.png HTTP/1.1" 304 - 127.0.0.1 - - [02/Apr/2022 13:59:32] "GET /?debugger=yes&cmd=resource&f=console.png HTTP/1.1" 304 -

v-chojas commented 2 years ago

Are you sure you're using Python 3.7 ? Those paths say 3.8.

khaihc commented 2 years ago

Are you sure you're using Python 3.7 ? Those paths say 3.8.

oh sorry, I just downgraded to 3.7 and still got the same error

gordthompson commented 2 years ago

https://stackoverflow.com/a/19549035/2144390

afrinjamanbd commented 2 years ago

Checked Everything including python path, version , dependencies etc. Nothing works.

robertoOlmedo commented 2 years ago

Here https://docs.microsoft.com/en-us/azure/databricks/kb/libraries/install-pyodbc-on-cluster In Set up solution in a single notebook