ImportError: cannot import name 'ULID' from 'ulid'
William9Baker opened this issue · comments
I've encountered the problem with this ERROR, but I can import ulid successfully. Somebody can help me?
Please elaborate on your problem, with code examples, versions etc. Providing reproducible steps would help.
Yes, please provide an example. ULID
is there. https://github.com/ahawker/ulid/blob/master/ulid/__init__.py#L31
I've got the same issue.
I use Azure Databricks and my library published in PyPI and references ulid.
When I install my library with command %pip install syngen
it successfully completes.
But when I try to use the library I get
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
File <command-3240490407258508>:1, in <cell line: 1>()
----> 1 from syngen import train
3 launch_train(metadata_path='/dbfs/FileStore/configuration/purchase_orders_dbfs.yml')
File /databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py:171, in _create_import_patch.<locals>.import_patch(name, globals, locals, fromlist, level)
166 thread_local._nest_level += 1
168 try:
169 # Import the desired module. If you’re seeing this while debugging a failed import,
170 # look at preceding stack frames for relevant error information.
--> 171 original_result = python_builtin_import(name, globals, locals, fromlist, level)
173 is_root_import = thread_local._nest_level == 1
174 # `level` represents the number of leading dots in a relative import statement.
175 # If it's zero, then this is an absolute import.
File /local_disk0/.ephemeral_nfs/envs/pythonEnv-4230ba91-9158-46fb-ad05-a452a2e5a079/lib/python3.9/site-packages/syngen/train.py:8, in <module>
5 import click
6 from loguru import logger
----> 8 from syngen.ml.worker import Worker
11 @click.command()
12 @click.option("--metadata_path", type=str, default=None, help="Path to the metadata file")
13 @click.option("--source", type=str, default=None, help="Path to the table that you want to use as a reference")
(...)
36 batch_size: int = 32,
37 ):
38 """
39 Launch the work of training process
40
(...)
52
53 """
File /databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py:171, in _create_import_patch.<locals>.import_patch(name, globals, locals, fromlist, level)
166 thread_local._nest_level += 1
168 try:
169 # Import the desired module. If you’re seeing this while debugging a failed import,
170 # look at preceding stack frames for relevant error information.
--> 171 original_result = python_builtin_import(name, globals, locals, fromlist, level)
173 is_root_import = thread_local._nest_level == 1
174 # `level` represents the number of leading dots in a relative import statement.
175 # If it's zero, then this is an absolute import.
File /local_disk0/.ephemeral_nfs/envs/pythonEnv-4230ba91-9158-46fb-ad05-a452a2e5a079/lib/python3.9/site-packages/syngen/ml/worker/__init__.py:1, in <module>
----> 1 from syngen.ml.worker.worker import Worker
File /databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py:171, in _create_import_patch.<locals>.import_patch(name, globals, locals, fromlist, level)
166 thread_local._nest_level += 1
168 try:
169 # Import the desired module. If you’re seeing this while debugging a failed import,
170 # look at preceding stack frames for relevant error information.
--> 171 original_result = python_builtin_import(name, globals, locals, fromlist, level)
173 is_root_import = thread_local._nest_level == 1
174 # `level` represents the number of leading dots in a relative import statement.
175 # If it's zero, then this is an absolute import.
File /local_disk0/.ephemeral_nfs/envs/pythonEnv-4230ba91-9158-46fb-ad05-a452a2e5a079/lib/python3.9/site-packages/syngen/ml/worker/worker.py:7, in <module>
3 from copy import deepcopy
5 from loguru import logger
----> 7 from syngen.ml.data_loaders import MetadataLoader
8 from syngen.ml.strategies import TrainStrategy, InferStrategy
9 from syngen.ml.reporters import Report
File /databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py:171, in _create_import_patch.<locals>.import_patch(name, globals, locals, fromlist, level)
166 thread_local._nest_level += 1
168 try:
169 # Import the desired module. If you’re seeing this while debugging a failed import,
170 # look at preceding stack frames for relevant error information.
--> 171 original_result = python_builtin_import(name, globals, locals, fromlist, level)
173 is_root_import = thread_local._nest_level == 1
174 # `level` represents the number of leading dots in a relative import statement.
175 # If it's zero, then this is an absolute import.
File /local_disk0/.ephemeral_nfs/envs/pythonEnv-4230ba91-9158-46fb-ad05-a452a2e5a079/lib/python3.9/site-packages/syngen/ml/data_loaders/__init__.py:1, in <module>
----> 1 from syngen.ml.data_loaders.data_loaders import (
2 CSVLoader,
3 AvroLoader,
4 DataLoader,
5 MetadataLoader,
6 YAMLLoader,
7 BaseDataLoader,
8 BinaryLoader
9 )
File /databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py:171, in _create_import_patch.<locals>.import_patch(name, globals, locals, fromlist, level)
166 thread_local._nest_level += 1
168 try:
169 # Import the desired module. If you’re seeing this while debugging a failed import,
170 # look at preceding stack frames for relevant error information.
--> 171 original_result = python_builtin_import(name, globals, locals, fromlist, level)
173 is_root_import = thread_local._nest_level == 1
174 # `level` represents the number of leading dots in a relative import statement.
175 # If it's zero, then this is an absolute import.
File /local_disk0/.ephemeral_nfs/envs/pythonEnv-4230ba91-9158-46fb-ad05-a452a2e5a079/lib/python3.9/site-packages/syngen/ml/data_loaders/data_loaders.py:17, in <module>
15 from syngen.ml.validation_schema import validate_schema, configuration_schema
16 from syngen.ml.convertor import CSVConvertor, AvroConvertor
---> 17 from syngen.ml.utils import trim_string
20 class BaseDataLoader(ABC):
21 """
22 Abstract class for data loader
23 """
File /databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py:171, in _create_import_patch.<locals>.import_patch(name, globals, locals, fromlist, level)
166 thread_local._nest_level += 1
168 try:
169 # Import the desired module. If you’re seeing this while debugging a failed import,
170 # look at preceding stack frames for relevant error information.
--> 171 original_result = python_builtin_import(name, globals, locals, fromlist, level)
173 is_root_import = thread_local._nest_level == 1
174 # `level` represents the number of leading dots in a relative import statement.
175 # If it's zero, then this is an absolute import.
File /local_disk0/.ephemeral_nfs/envs/pythonEnv-4230ba91-9158-46fb-ad05-a452a2e5a079/lib/python3.9/site-packages/syngen/ml/utils/__init__.py:1, in <module>
----> 1 from syngen.ml.utils.utils import (
2 get_date_columns,
3 get_nan_labels,
4 nan_labels_to_float,
5 get_tmp_df,
6 fillnan,
7 fetch_dataset,
8 slugify_attribute,
9 slugify_parameters,
10 inverse_dict,
11 get_nan_labels,
12 trim_string,
13 convert_to_time,
14 check_if_features_assigned,
15 fetch_training_config,
16 generate_uuid,
17 generate_uuids
18 )
File /databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py:171, in _create_import_patch.<locals>.import_patch(name, globals, locals, fromlist, level)
166 thread_local._nest_level += 1
168 try:
169 # Import the desired module. If you’re seeing this while debugging a failed import,
170 # look at preceding stack frames for relevant error information.
--> 171 original_result = python_builtin_import(name, globals, locals, fromlist, level)
173 is_root_import = thread_local._nest_level == 1
174 # `level` represents the number of leading dots in a relative import statement.
175 # If it's zero, then this is an absolute import.
File /local_disk0/.ephemeral_nfs/envs/pythonEnv-4230ba91-9158-46fb-ad05-a452a2e5a079/lib/python3.9/site-packages/syngen/ml/utils/utils.py:12, in <module>
10 import pickle as pkl
11 import uuid
---> 12 from ulid import ULID
13 from uuid import UUID
14 import random
ImportError: cannot import name 'ULID' from 'ulid' (/local_disk0/.ephemeral_nfs/envs/pythonEnv-4230ba91-9158-46fb-ad05-a452a2e5a079/lib/python3.9/site-packages/ulid.py)
@tdspora checking your results, I've never used syngen and don't know what it is. yet checking its repository, in its reuqirements.txt, you can see that it actually installs py-ulid
. https://github.com/tdspora/syngen/blob/50402aaf418300ba07fef79be761b0685dff2b9a/requirements.txt#L30
That is a different package: https://github.com/itsrainingmani/py-ulid
For this package to be used, the requirement is ulid-py
.
So I believe, the requirement points to a different package (py-ulid
) but the code is trying to use it as this one? (ulid-py
).
Oh! Sorry.