Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ModuleNotFoundError: import of fnmatch halted; None in sys.modules

See original GitHub issue

I’m trying to use records with Snowflake (dwh solution in the cloud), and I do get results but I always get the ModuleNotFoundError error.

It works without any problems when I use just SqlAlchemy using snowflake-sqlalchemy, so that makes me think it’s something records specific. I really like the product and, although my resources are limited, I’m willing to assist or provide more information if requested.

I’m running Python 3.7.2, installed through homebrew, in a virtualenv on MacOS 10.14.3.

Installed packages:

pip install records snowflake-sqlalchemy

Code to reproduce (credentials and account are obviously not the ones I use):

import records
from sqlalchemy import create_engine

connection_params = dict(

connection_string = 'snowflake://{user}:{password}@{account}/{database}/{schema}'
db_string = connection_string.format(**connection_params)

query = 'select * from table limit 10'

db = records.Database(db_string)
rows = db.query(query)
for row in rows:


Exception during reset or similar
Traceback (most recent call last):
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/sqlalchemy/", line 742, in _finalize_fairy
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/sqlalchemy/", line 929, in _reset
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/sqlalchemy/engine/", line 486, in do_rollback
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/snowflake/connector/", line 508, in rollback
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/snowflake/connector/", line 479, in execute
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/snowflake/connector/", line 369, in _execute_helper
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/snowflake/connector/", line 784, in cmd_query
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/snowflake/connector/", line 313, in request
    timeout=timeout, _include_retry_params=_include_retry_params)
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/snowflake/connector/", line 530, in _post_request
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/snowflake/connector/", line 608, in fetch
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/snowflake/connector/", line 685, in _request_exec_wrapper
    raise e
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/snowflake/connector/", line 648, in _request_exec_wrapper
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/snowflake/connector/", line 873, in _request_exec
    raise err
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/snowflake/connector/", line 776, in _request_exec
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/botocore/vendored/requests/", line 456, in request
    prep.url, proxies, stream, verify, cert
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/botocore/vendored/requests/", line 614, in merge_environment_settings
    env_proxies = get_environ_proxies(url) or {}
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/botocore/vendored/requests/", line 534, in get_environ_proxies
    if should_bypass_proxies(url):
  File "/Users/optroodt/virtualenvs/records/lib/python3.7/site-packages/botocore/vendored/requests/", line 523, in should_bypass_proxies
    bypass = proxy_bypass(netloc)
  File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/", line 2610, in proxy_bypass
    return proxy_bypass_macosx_sysconf(host)
  File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/", line 2587, in proxy_bypass_macosx_sysconf
    return _proxy_bypass_macosx_sysconf(host, proxy_settings)
  File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/", line 2534, in _proxy_bypass_macosx_sysconf
    from fnmatch import fnmatch
ModuleNotFoundError: import of fnmatch halted; None in sys.modules


Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:13

github_iconTop GitHub Comments

peterolivecommented, May 22, 2019

@optroodt You need to close the connection and dispose the engine. Try add the following at the end:

samiskencommented, Mar 3, 2020

@peterolive thanks! This solved my issue with this error

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot find time module when changed sys.modules[__name__]
A slightly terrible fix: attach it to the class Hello . import sys class Hello: import time #Yes, the import statement in the...
Read more >
Issue 31642: None value in sys.modules no longer blocks import
An import error raised when import was blocked by setting None in sys. modules was not silenced because it has different error message....
Read more >
import of time halted; none in sys.modules - 七牛云
ModuleNotFoundError : import of time halted; none in sys.modules.
Read more >
ModuleNotFoundError: import of time ha.. -
ModuleNotFoundError : import of time halted; None in sys.modules occured when Object gets out of scope(__del__) python,modulenotfounderror,6,3.
Read more >
vocab.txt - Hugging Face
... shape ##vel logger specifi ##ant files count import iter ##oc exist debug ... datas lines ##ments dtype refer scal orig sys graph...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found