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

Importing a module no longer works #1118

Closed
andy31lewis opened this issue May 22, 2019 · 2 comments
Closed

Importing a module no longer works #1118

andy31lewis opened this issue May 22, 2019 · 2 comments

Comments

@andy31lewis
Copy link

andy31lewis commented May 22, 2019

Importing a module worked correctly in 3.7.1 but in 3.7.2 the import fails with "ImportError: No module named xxxxxxx".
This is the case no matter whether the module is a file module.py, or a folder containing an __init__.py file, or an import from within a folder import folder.module as mymodule.

Having done some digging, I find that the change seems to have been introduced in commit 4894051 Fixes #1093 : wrong assignment in "for x in empty range", on April 17th, although I can't see what that title has to do with importing a module :-)

Thank you as always
Andy

@andy31lewis andy31lewis changed the title A folder containing a file __init__.py no longer treated as a module Importing a module no longer works May 22, 2019
@PierreQuentel
Copy link
Contributor

Many thanks for reporting this very soon after the release of version 3.7.2... It's the kind of bug that doesn't show in the development environment, but crashes everything in an environment created by python -m brython --install. I have published release 3.7.3 with a bug fix.

By the way, the bug was indeed introduced by the previous commit, 6c8b2fa, with a name more related to the issue : Limit the number of tries when importing from a module in the standard library

@darthglowball
Copy link

darthglowball commented Aug 4, 2019

I try to import regex module from a Brython script in my Client folder. regex is located at ...\Client\resources\backend\javascript_packages\Brython\Lib\site-packages\regex. I do:

import regex and I get this error:

Error 0 means that Python module regex was not found at url file:///C:/Users/hp/Documents/Programming/Web%20development/File%20content%20searcher%20and%20categorizer/Client/regex.py
brython.js:8724 Failed to load resource: net::ERR_FILE_NOT_FOUND
brython.js:8729 Error 0 means that Python module regex was not found at url file:///C:/Users/hp/Documents/Programming/Web%20development/File%20content%20searcher%20and%20categorizer/Client/regex/__init__.py
brython.js:8724 Failed to load resource: net::ERR_FILE_NOT_FOUND
brython.js:8729 Error 0 means that Python module regex was not found at url file:///C:/Users/hp/Documents/Programming/Web%20development/File%20content%…t/resources/backend/javascript_packages/Brython/Lib/site-packages/regex.py
brython.js:8724 Failed to load resource: net::ERR_FILE_NOT_FOUND
brython.js:8729 Error 0 means that Python module regex was not found at url file:///C:/Users/hp/Documents/Programming/Web%20development/File%20content%…es/backend/javascript_packages/Brython/Lib/site-packages/regex/__init__.py
brython.js:5979 Traceback (most recent call last):
ImportError: No module named regex
brython.js:5124 Uncaught Error
    at Object._b_.ImportError.$factory (eval at $make_exc (brython.js:7501), <anonymous>:71:321)
    at Object.import_hooks (brython.js:13227)
    at $B.$__import__ (brython.js:9028)
    at Object.$B.$import (brython.js:9061)
    at eval (eval at $B.loop (brython.js:5108), <anonymous>:20:8)
    at $B.loop (brython.js:5108)
    at $B.inImported (brython.js:5098)
    at $B.loop (brython.js:5114)
    at IDBOpenDBRequest.idb_cx.onsuccess (brython.js:5078)

I'm using CEF.
the init.py contains from .regex import *. In the regex folder there is is a regex.py script.
The init.py is present in the regex folder. If you look at the part regex was not found at url file:///C:/Users/hp/Documents/Programming/Web%20development/File%20content%…es/backend/javascript_packages/Brython/Lib/site-packages/regex/__init__.py it looks like resources folder isn't present, but there's ...es which I think is an abbreviation for that folder. So the error shows the right paths to check, but the module isn't found. I'm 100% sure that the modules are in the correct folders with the correct names.

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

No branches or pull requests

3 participants