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: cannot import name file_lock when running server #1157

Open
StephanHeijl opened this issue Dec 31, 2015 · 7 comments
Open

ImportError: cannot import name file_lock when running server #1157

StephanHeijl opened this issue Dec 31, 2015 · 7 comments

Comments

@StephanHeijl
Copy link

After installing brat according to the standard installation procedure, I run into the error: ImportError: cannot import name file_lock. Complete Traceback:

Traceback (most recent call last):
  File "/home/stephan/public_html/brat/server/src/server.py", line 321, in serve
    return _safe_serve(params, client_ip, client_hostname, cookie_data)
  File "/home/stephan/public_html/brat/server/src/server.py", line 170, in _safe_serve
    from dispatch import dispatch
  File "/home/stephan/public_html/brat/server/src/dispatch.py", line 15, in <module>
    from annotator import create_arc, delete_arc, reverse_arc
  File "/home/stephan/public_html/brat/server/src/annotator.py", line 20, in <module>
    from annotation import (OnelineCommentAnnotation, TEXT_FILE_SUFFIX,
  File "/home/stephan/public_html/brat/server/src/annotation.py", line 28, in <module>
    from filelock import file_lock
ImportError: cannot import name file_lock

This happens in v1.3, as well as the latest version from master. I am using Python 2.7.10 to run brat. This happens when the server is run from Apache2 as well as with the standalone server. Navigating to the server/src directory and running from filelock import file_lock in the REPL does not result in any errors.

Similar errors normally result from cyclical imports, but that is not the case here, since filelock does not import anything other then standard libraries.

Does anyone have a clue as to how to get brat running?

@ghost
Copy link

ghost commented Jan 1, 2016

Which OS are you on?

@StephanHeijl
Copy link
Author

64bit Kubuntu 15.10 with the Linux 4.2.0-18-generic kernel (default).

@StephanHeijl
Copy link
Author

I got brat running using a Docker image, so it looks like it's either got something to do with the Python version (2.7.10 vs 2.7.6 in the Docker image) or the surrounding environment. Can refute the former on their systems?

@deka108
Copy link

deka108 commented Oct 10, 2016

Check your filelock library. Are you using filelock 2.0.6 (https://pypi.python.org/pypi/filelock/) as well? I solved mine by changing all the mentioned file_lock in "server/src/annotation.py" to FileLock

@napsternxg
Copy link

I was facing the same issue. I inspected the source and found that there is a filelock.py module defined in server/src folder which is imported in annotation.py and backup.py. I have renamed the file to filelock_brat.py and fixed the imports which results in the proper working of the standalone file.

napsternxg added a commit to napsternxg/brat that referenced this issue Nov 28, 2016
Fixed the filename which was causing the problems.
Fixed imports of the file.
@kaushikacharya
Copy link

@napsternxg
Your changes fixes ImportError: cannot import name file_lock.
But are you not facing the standalone os.fork() crash issue: #993 ?

@eugene-yang
Copy link

eugene-yang commented Jun 18, 2018

My solution for this is just using a conda environment and uninstall filelock.

I will suggest to include a python package dependency file instead of including the specific version of python package into the repository.
Using a dependency file will make the life of people using any form of environment a lot easier.

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

5 participants