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

External file loading problem with pdpipe import #103

Open
shaypal5 opened this issue Jun 24, 2022 Discussed in #97 · 4 comments
Open

External file loading problem with pdpipe import #103

shaypal5 opened this issue Jun 24, 2022 Discussed in #97 · 4 comments
Assignees
Labels

Comments

@shaypal5
Copy link
Collaborator

Discussed in #97

Originally posted by Dranikf March 14, 2022
Will start with example. I create test.py file in some dir, it may looks like this:

from sys import path
import pdpipe

path.append("<path to external folder>/some_external_folder")
import temp

In ".../some_external_folder" i have added temp.py file, which contains 'hello world' printing. When I try to run first file i have a error:

Traceback (most recent call last):
  File "<first file folder path>/test.py", line 6, in <module>
    import temp
ModuleNotFoundError: No module named 'temp'

But when i rem import pdpipe program starts. What can cause this behavior and how to correct it?

@shaypal5 shaypal5 added the bug label Jun 24, 2022
@shaypal5 shaypal5 self-assigned this Jun 24, 2022
@shaypal5
Copy link
Collaborator Author

Update: Even when I delete the only piece of my code using sys, the error presists. :/

See this method:

def __load_stage_attributes_from_module__(module_name: object) -> None:

@DavidKatz-il
Copy link
Contributor

This one is working fine

import pdpipe
from sys import path

path.append("<path to external folder>/some_external_folder")

import temp

This one is raising ModuleNotFoundError

from sys import path
import pdpipe

path.append("<path to external folder>/some_external_folder")

import temp

This is due to the import of the nltk package here.
The above error was not raised after removing this import.

@DavidKatz-il
Copy link
Contributor

import sys

# Hack to keep NLTK's "tokenize" module from colliding with the "tokenize" in
# the Python standard library.
OLD_SYS_PATH = sys.path[:]
sys.path = [p for p in sys.path if p and "nltk" not in str(p)]
import inspect

sys.path = OLD_SYS_PATH

https://github.com/nltk/nltk/blob/develop/nltk/decorators.py#L18-L26

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

No branches or pull requests

2 participants