I'm getting the following Import Error when importing the sutime module - what does it mean?
Asked Answered
L

2

1

I'm getting this error:

ImportError: cannot import name 'SUTime' from partially initialized module 'sutime' (most likely due to a circular import)

when importing the sutime module as:

from sutime import SUTime

as suggested in the sutime GitHub example: https://github.com/FraBle/python-sutime

Context: sutime is a Python library for parsing date/time from a natural language input, developed by the amazing team over at Stanford CoreNLP.

Note: I've already run the pre-req installs as well:

>> pip install setuptools_scm jpype1 # install pre-reqs
>> pip install sutime
>> # use package pom.xml to install all Java dependencies via Maven into ./jars
>> mvn dependency:copy-dependencies -DoutputDirectory=./jars
Leekgreen answered 15/1, 2020 at 0:30 Comment(0)
A
1

It's not true that a circular import is the most likely cause of your error. A failed, incomplete, or in some way strange installation is more likely. Try this:

pip uninstall sutime
pip uninstall jpype1
pip uninstall setuptools_scm
pip3 install setuptools_scm jpype1  # note: pip3
pip3 install sutime

Then, in the python-sutime directory, enter this command:

./test.sh

It should output lots of log lines, and the last line but one should be similar to this:

======================== 5 passed, 2 warnings in 13.06s ========================

In the same directory you can enter and run the Python script from the Example section of the README. It should output many log lines before the reported output. There may be a way to avoid that, but anyway it happens only once, when the script starts.

Absher answered 15/1, 2020 at 22:59 Comment(5)
I've gone through those steps above, but getting the same error :( I entered the command and got this return: zsh: no such file or directory: ./test.shLeekgreen
Ohhhhhhhhh I figured out the problem. I had named my script sutime.py which is definitely the issue. Now, I'm only getting the following error (progress!): /Library/Frameworks/Python.framework/Versions/3.8/bin/python3: can't open file 'sutime.py': [Errno 2] No such file or directoryLeekgreen
when you do what, exactly, and in what directory?Absher
Running my Python script with from sutime import SUTime at the top, from my Desktop (the folder where I've got my script)Leekgreen
try to move (or copy) your script to the checkout directory of the python-sutime project (should be called python-sutime), and run it from thereAbsher
J
0
  1. Clone the git repo. -

    !git clone https://github.com/FraBle/python-sutime.git

  2. Go to the python-sutime/sutime in the cloned repo. There is a pom.xml file. Open the terminal and issue the following command.

    mvn dependency:copy-dependencies -DoutputDirectory=./jars -P english

  3. Now you can simply import the sutime from the sutime.py script in the cloned repo folder.

  4. If you want to use sutime from anywhere, install sutime using...

    pip install sutime

and replace the /usr/local/lib/python3.6/dist-packages/sutime folder with the sutime folder you get after step 2.

Jemie answered 7/3, 2021 at 7:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.