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

ImportError: No module named ... in reload_plugin #1744

Closed
evandrocoan opened this issue Jun 3, 2017 · 3 comments
Closed

ImportError: No module named ... in reload_plugin #1744

evandrocoan opened this issue Jun 3, 2017 · 3 comments

Comments

@evandrocoan
Copy link

evandrocoan commented Jun 3, 2017

I am not sure if this is a bug, but seems a funny fact, I spend some time trying to figure it out why the package was not loading. Just happened when I renamed the file, but add an extra .py extension.

This other issue seems related:

  1. Loading plugins from "Installed Packages" fails if a corresponding dir exists in "Packages" #55 Loading plugins from "Installed Packages" fails if a corresponding dir exists in "Packages"

Expected behavior

Correctly load the package names pack.py.py as:

reloading plugin Pack.pack.py.py

instead of:

reloading plugin Pack.pack.py
Traceback (most recent call last)
...

Actual behavior

reloading plugin Pack.pack.py
Traceback (most recent call last):
  File "D:\SublimeText\sublime_plugin.py", line 109, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1512, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1529, in _find_and_load_unlocked
ImportError: No module named 'Pack.pack'

Steps to reproduce

  1. Create the file pack.py.py on folder Pack at the Sublime Text Packages directory:
import sublime
import sublime_plugin

class IndentSelectWholeFirstLineEventListener(sublime_plugin.EventListener):
    """
        Sublime Text 3: Keep entire lines selected when indenting with tab
        https://stackoverflow.com/questions/24688117
    """

    def on_post_text_command(self, view, command_name, args):

        if command_name == 'indent':

            if all(not sel.empty() for sel in view.sel()):

                if all(view.line(sel.begin()) != view.line(sel.end()) for sel in view.sel()):
                    new_selections = []

                    for sel in view.sel():
                        new_selections.append(sel.cover(view.line(sel.begin())))

                    view.sel().clear()
                    view.sel().add_all(new_selections)

Now you will see on the console the error message.

Environment

  • Operating system and version:
    • Windows 10 build 15063 (x64)
    • Mac OS ...
    • Linux ...
  • Monitor:
    • Resolution 1920x1080
    • dpi_scale used in ST 1.0
  • Sublime Text:
    • Build 3133
    • 32 bit (x86)
@wbond
Copy link
Member

wbond commented Jun 5, 2017

This is really more of an issue that Python treats . as a module separator. If you try to add a . to a Python file and import it using the . in the module name for that filename, I believe it is going to do the same thing.

@keith-hall keith-hall added tagme and removed T: bug labels Jun 5, 2017
@FichteFoll
Copy link
Collaborator

I suggest a wontfix. Trying to work around this limitation of Python is just not feasible and the workaround is absolutely trivial: Just don't use dots in your file or module names.

@evandrocoan
Copy link
Author

I am not sure why I opened it. Let us KISS (Keep It Simple Stupid).

I think it is related to:

  1. Test against package names containing periods wbond/package_control_channel#2524 Test against package names containing periods

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

No branches or pull requests

4 participants