I am beginner in Django framework and trying to connect Django project with MS sQL server on my localhost. I have tried a few of libs like pyodbc-azure but it is not working in my case and I am getting the errors.
"C:\Program Files\JetBrains\PyCharm 2018.1.5\bin\runnerw.exe"
"C:\Program Files (x86)\Python37-32\python.exe"
C:/Users/hyaqub/PycharmProjects/SpotDash/manage.py runserver 8000
Unhandled exception in thread started by .wrapper at 0x04A1BD68> Traceback (most recent
call last): File "C:\Program Files
(x86)\Python37-32\lib\site-packages\django_pyodbc\base.py", line 55,
in import pyodbc as Database ImportError: DLL load failed:
The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Program Files
(x86)\Python37-32\lib\site-packages\django\utils\autoreload.py", line
225, in wrapper fn(*args, **kwargs) File "C:\Program Files
(x86)\Python37-32\lib\site-packages\django\core\management\commands\runserver.py",
line 109, in inner_run autoreload.raise_last_exception() File
"C:\Program Files
(x86)\Python37-32\lib\site-packages\django\utils\autoreload.py", line
248, in raise_last_exception raise _exception[1] File "C:\Program
Files
(x86)\Python37-32\lib\site-packages\django\core\management__init__.py",
line 337, in execute autoreload.check_errors(django.setup)() File
"C:\Program Files
(x86)\Python37-32\lib\site-packages\django\utils\autoreload.py", line
225, in wrapper fn(*args, **kwargs) File "C:\Program Files
(x86)\Python37-32\lib\site-packages\django__init__.py", line 24, in
setup apps.populate(settings.INSTALLED_APPS) File "C:\Program Files
(x86)\Python37-32\lib\site-packages\django\apps\registry.py", line
112, in populate app_config.import_models() File "C:\Program Files
(x86)\Python37-32\lib\site-packages\django\apps\config.py", line 198,
in import_models self.models_module =
import_module(models_module_name) File "C:\Program Files
(x86)\Python37-32\lib\importlib__init__.py", line 127, in
import_module return _bootstrap._gcd_import(name[level:], package,
level) File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load File
"", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked File
"", line 728, in exec_module
File "", line 219, in
_call_with_frames_removed File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\contrib\auth\models.py",
line 2, in from django.contrib.auth.base_user import
AbstractBaseUser, BaseUserManager File "C:\Program Files
(x86)\Python37-32\lib\site-packages\django\contrib\auth\base_user.py",
line 47, in class AbstractBaseUser(models.Model): File
"C:\Program Files
(x86)\Python37-32\lib\site-packages\django\db\models\base.py", line
101, in new new_class.add_to_class('_meta', Options(meta,
app_label)) File "C:\Program Files
(x86)\Python37-32\lib\site-packages\django\db\models\base.py", line
305, in add_to_class value.contribute_to_class(cls, name) File
"C:\Program Files
(x86)\Python37-32\lib\site-packages\django\db\models\options.py", line
203, in contribute_to_class self.db_table =
truncate_name(self.db_table, connection.ops.max_name_length()) File
"C:\Program Files
(x86)\Python37-32\lib\site-packages\django\db__init__.py", line 33,
in getattr return getattr(connections[DEFAULT_DB_ALIAS], item) File
"C:\Program Files
(x86)\Python37-32\lib\site-packages\django\db\utils.py", line 202, in
getitem backend = load_backend(db['ENGINE']) File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\utils.py", line 110, in
load_backend return import_module('%s.base' % backend_name) File
"C:\Program Files (x86)\Python37-32\lib\importlib__init__.py", line
127, in import_module return _bootstrap._gcd_import(name[level:],
package, level) File "C:\Program Files
(x86)\Python37-32\lib\site-packages\django_pyodbc\base.py", line 58,
in raise ImproperlyConfigured("Error loading pyodbc module:
%s" % e) django.core.exceptions.ImproperlyConfigured: Error loading
pyodbc module: DLL load failed: The specified module could not be
found.
Please guide me how can I achieve this. It would be appreciated.
The error states that you are missing a DLL/module. I am not sure what process you went to install, but these instructions state that you need Install the Microsoft ODBC Driver for SQL Server on Windows, which should include all of the necessary DLL's
Related
I am working on django project. And testing Sql Server database.
I am using korean linux hosting service gabia. So I don't have any root access.
Even this hosting company blocked yum and rpm.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libodbc.so.2: cannot open shared object file: No such file or directory
I am keep having this kind of trouble when I import pyodbc. But I can fully use pymssql module.
I have no idea what is wrong with this linux...
This is when I connect django to mssql database with mssql-django package.
Traceback (most recent call last):
File "/web/.local/lib/python3.9/site-packages/mssql/base.py", line 16, in <module>
import pyodbc as Database
ImportError: libodbc.so.2: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/web/.local/lib/python3.9/site-packages/django/core/handlers/wsgi.py", line 130, in __call__
signals.request_started.send(sender=self.__class__, environ=environ)
File "/web/.local/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 176, in send
return [
File "/web/.local/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
(receiver, receiver(signal=self, sender=sender, **named))
File "/web/.local/lib/python3.9/site-packages/django/db/__init__.py", line 46, in reset_queries
for conn in connections.all():
File "/web/.local/lib/python3.9/site-packages/django/utils/connection.py", line 76, in all
return [self[alias] for alias in self]
File "/web/.local/lib/python3.9/site-packages/django/utils/connection.py", line 76, in <listcomp>
return [self[alias] for alias in self]
File "/web/.local/lib/python3.9/site-packages/django/utils/connection.py", line 62, in __getitem__
conn = self.create_connection(alias)
File "/web/.local/lib/python3.9/site-packages/django/db/utils.py", line 208, in create_connection
backend = load_backend(db["ENGINE"])
File "/web/.local/lib/python3.9/site-packages/django/db/utils.py", line 113, in load_backend
return import_module("%s.base" % backend_name)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/web/.local/lib/python3.9/site-packages/mssql/base.py", line 18, in <module>
raise ImproperlyConfigured("Error loading pyodbc module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading pyodbc module: libodbc.so.2: cannot open shared object file: No such file or directory
This linux is CentOS 7
I've tried to install unixODBC on /web/.local directory which I can access into. And I successfully executed unixodbc alone, but not with python pyodbc.
I failed to install FreeTDS because I cannot find any way to install FreeTDS on this linux with tar file.
I wonder if I can change the installation path written on pyodbc package file. If I can, then I can fix this problem with changing the installation root of unixODBC to my accessable directory.
We have an application that uses firestore. It is running on Python 3.x on standard Google app engine. The application was running fine, till this morning when we tried to run the new version. The deployment of the new version is executed without any error. The requirement.txt is as follows -
firebase_admin==3.0.0
sendgrid==6.9.3
google-auth==1.35.0
google-auth-httplib2==0.1.0
jinja2==3.0.3
MarkupSafe==2.0.1
pytz==2021.3
Flask==2.0.2
twilio==6.46.0
httplib2==0.20.2
requests==2.24.0
requests_toolbelt==0.9.1
google-cloud-tasks==2.7.1
google-cloud-logging==1.15.1
googleapis-common-protos==1.54.0
protobuf==3.20.1
We get the following error.
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 55, in <module>
from google.cloud.location import locations_pb2 # type: ignore
ModuleNotFoundError: No module named 'google.cloud.location'
Please help.
Updated (9-24-2022) with the complete error output.
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
worker.init_process()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 92, in init_process
super().init_process()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/util.py", line 359, in import_app
mod = importlib.import_module(module)
File "/opt/python3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/srv/main.py", line 8, in <module>
from controllers import server, common, header
File "/srv/controllers/server.py", line 19, in <module>
from controllers import basehandler
File "/srv/controllers/basehandler.py", line 12, in <module>
from google.cloud import firestore
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore/__init__.py", line 18, in <module>
from google.cloud.firestore_v1 import __version__
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/__init__.py", line 36, in <module>
from google.cloud.firestore_v1.async_client import AsyncClient
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/async_client.py", line 45, in <module>
from google.cloud.firestore_v1.async_transaction import AsyncTransaction
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/async_transaction.py", line 49, in <module>
from google.cloud.firestore_v1.client import Client
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/client.py", line 44, in <module>
from google.cloud.firestore_v1.services.firestore import client as firestore_client
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/services/firestore/__init__.py", line 16, in <module>
from .client import FirestoreClient
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 55, in <module>
from google.cloud.location import locations_pb2 # type: ignore
ModuleNotFoundError: No module named 'google.cloud.location'
It looks like Google made a mistake in setting requirements for one its Python packages.
If you create a new virtual environment, install with pip install -r you should be able to recreate the error you are seeing in production.
To fix it, I would do pip list on your local machine (in the environment that is still working) and add fixed versions of other installed google packages until it works.
You can test by creating a new Python virtual environment, installing with pip install -r and seeing if it works.
It is a tedious process unfortunately.
I got this exact same error just now while trying to link a Python script to Firestore. I don't know if this is a "correct" solution but I got my code to run and save data to my Firestore database after this doing this.
In the error message, this line specifies the file where google.cloud.location is being imported:
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 55, in <module>
If you open the client.py file and comment out the line 55 ("from google.cloud.location import locations_pb2 # type: ignore"), then run your code again, the next error message will show the other file where google.cloud.location is being imported. Repeat this process for all five files where this module is imported. (client.py, base.py, grpc.py, grpc_asyncio.py, async_client.py)
From searching through the code, I'm seeing that locations_pb2 (imported from google.cloud.location) is never used. I suspect that commenting this out entirely won't affect the functionality of firebase_admin.
I am following this tutorial for user authentication on GAE, endpoints v2 in Python.
I use their code EXACTLY (only pasting in my app ID).
Running the code locally via PyCharm, it doesn't like the type of "issuers" wanting a dict: TypeError: issuers type doesn't match .
Has it something to do with IDE integration not being supported yet? What am I overlooking?
In full:
ERROR 2017-06-05 15:23:19,417 wsgi.py:263]
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "C:\Users(...)\web app\goal.py", line 103, in <module>
issuers=[firebase_issuer])
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\protorpc-1.0\protorpc\util.py", line 173, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Users\(...)\web app\lib\endpoints\api_config.py", line 976, in api
api_key_required=api_key_required, base_path=base_path)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\protorpc-1.0\protorpc\util.py", line 173, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Users\(...)\web app\lib\endpoints\api_config.py", line 469, in __init__
base_path=base_path)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\protorpc-1.0\protorpc\util.py", line 173, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Users\(...)\web app\lib\endpoints\api_config.py", line 550, in __init__
_CheckType(issuers, dict, 'issuers')
File "C:\Users\(...)\web app\lib\endpoints\api_config.py", line 195, in _CheckType
raise TypeError('%s type doesn\'t match %s.' % (name, check_type))
TypeError: issuers type doesn't match <type 'dict'>.
Apologies for the incorrect documentation. You do need to pass a dict. So try issuers={'firebase': firebase_issuer} instead.
I believe this is related a number of python packages I have recently installed environmental variables that I have changed. I have re-installed Numpy and GAE, which did not help. So any suggestions on this? Thanks!
The GAE log indicated that the failure was lined to file import
2013-12-11 11:45:20 Running command: "['C:\\Python27\\pythonw.exe', 'C:\\Program Files (x86)\\Google\\google_appengine\\dev_appserver.py', '--skip_sdk_update_check=yes', '--port=8094', '--admin_port=8004', 'D:\\Dropbox\\ubertool_src']"
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 197, in <module>
_run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 193, in _run_file
execfile(script_path, globals_)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 27, in <module>
import tempfile
File "C:\Python27\Lib\tempfile.py", line 34, in <module>
from random import Random as _Random
File "C:\Python27\Lib\site-packages\numpy\random\__init__.py", line 102, in <module>
ranf = random = sample = random_sample
NameError: name 'random_sample' is not defined
2013-12-11 11:45:21 (Process exited with code 1)
Update
just did a little test.
I can run from numpy import random
but if I run import random
The error msg is:
>>> import random
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\Lib\site-packages\numpy\random\__init__.py", line 102, in <module>
ranf = random = sample = random_sample
NameError: name 'random_sample' is not defined
Update
The problem is solved after removing C:\Python27\Lib\site-packages\numpy (I am not sure how this was added) from PYTHONPATH in Environmental Variable
Good day to all. I am using Google App Engine 1.6.2 , Python 2.7 ,Windows 7x64, i created an application..uploded it...it was successfully working for about a weak. But when i was trying to make an update this morning, luncher gave me this error:
2012-02-20 12:26:41 Running command: "['C:\\Python27\\pythonw.exe', '-u', 'C:\\Program Files (x86)\\Google\\google_appengine\\appcfg.py', '--no_cookies', u'--email=myemail#gmail.com', '--passin', 'update', 'D:\\Dropbox\\Google\\handmade']"
Application: bubonchikhub; version: 1
Host: appengine.google.com
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 101, in <module>
run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 97, in run_file
execfile(script_path, globals_)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 3935, in <module>
main(sys.argv)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 3926, in main
result = AppCfgApp(argv).Run()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 2497, in Run
self.action(self)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 3692, in __call__
return method()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 2915, in Update
self.UpdateVersion(rpcserver, self.basepath, appyaml)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 2897, in UpdateVersion
updatecheck.CheckForUpdates()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 572, in CheckForUpdates
runtime=self.config.runtime)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appengine_rpc.py", line 365, in Send
f = self.opener.open(req)
File "C:\Python27\lib\urllib2.py", line 394, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 412, in _open
'_open', req)
File "C:\Python27\lib\urllib2.py", line 372, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1207, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "C:\Program Files (x86)\Google\google_appengine\lib\fancy_urllib\fancy_urllib\__init__.py", line 363, in do_open
url_error.reason.args[1])
fancy_urllib.InvalidCertificateException: Host 127.0.0.1:8888 returned an invalid certificate (_ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed):
To learn more, see http://code.google.com/appengine/kb/general.html#rpcssl
2012-02-20 12:26:43 (Process exited with code 1)
You can close this window now.
You can close this window now.
Can anyone help how to fix this?
Thnx in advance
Your request might be going through a local proxy.
Upgrading to Python 2.7.9 fixed this for me.
You need to paste your proxy's certification to the end of google_appengine/lib/cacerts/cacerts.txt
This does seem to be related to proxy servers, when I run fiddler and try to deploy I get this error. When I shut it down deployment works fine.
You will get an invalid certificate error like
fancy_urllib.InvalidCertificateException: Host 127.0.0.1:8888 returned an invalid certificate (_ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed):
So turn of the proxy server (assuming this is your issue) you are running and and the run the appcfg deploy!