I am using Python 3.6 and I have a strange import error. My Python file contains only the line import formic
. But when I execute the script, I get the following error:
from formic import FileSet, Pattern, get_version
ImportError: cannot import name 'FileSet'
I have tried installing Formic both with and without sudo
(yes, I know that I shouldn't use pip
with sudo
, but sometimes you get desperate)
I have used Formic before, but can't figure out what is going on in this situation.
If I only have import sys
, then the script runs just fine with no errors, as expected.
Any ideas why this error occurs? Or how to fix it?
Additional Information
I don't have a circular dependency, because Formic is a Python package https://stackoverflow.com/a/9252628/623541
I have deleted the __pycache__ folder https://stackoverflow.com/a/73954626/623541
I have tried fixing PYTHONPATH https://stackoverflow.com/a/15052360/623541
export PYTHONPATH=/home/myName/Workspace/myProject/.pyenv/lib/python3.6/site-packages
I have tried installing with
sudo -H
https://stackoverflow.com/a/52159621/623541I have tried installing Formic with
--no-cache-dir
https://stackoverflow.com/a/9510610/623541I have purged cache with
pip cache purge
I have tried fixing permissions in the site-packages directory. https://stackoverflow.com/a/16377297/623541
I have verified that Formic is installed:
$ /home/myName/Workspace/myProject/.pyenv/bin/pip3 show formic
Name: formic
Version: 0.9b8
Summary: An implementation of Apache Ant FileSet and Globs
Home-page: http://www.aviser.asia/formic
Author: Aviser LLP, Singapore
Author-email: formic@aviser.asia
License: GPLv3+
Location: /home/myName/Workspace/myProject/.pyenv/lib/python3.6/site-packages
Requires:
Required-by:
But if I try to import Formic from the same Python, it fails:
$ /home/myName/Workspace/myProject/.pyenv/bin/python
Python 3.6.9 (default, Jun 29 2022, 11:45:57)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import formic
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/myName/Workspace/myProject/.pyenv/lib/python3.6/site-packages/formic/__init__.py", line 27, in <module>
from formic import FileSet, Pattern, get_version
ImportError: cannot import name 'FileSet'