ImportError in every `dvc command` after `pip install -e` in develop environment
See original GitHub issueBug Report
ImportError: cannot import name '__version__' from '_version' (/Users/gao/Code/dvc/dvc/_version.py)
After every dvc command didn’t affect the command running but quite anonying.
Description
Meet this error message after every command.
Traceback (most recent call last):
File "/Users/gao/Code/dvc/dvc/__main__.py", line 7, in <module>
sys.exit(main(sys.argv[1:]))
File "/Users/gao/Code/dvc/dvc/main.py", line 97, in main
if analytics.is_enabled():
File "/Users/gao/Code/dvc/dvc/analytics.py", line 50, in is_enabled
Config(validate=False).get("core", {}).get("analytics", "true")
File "/Users/gao/Code/dvc/dvc/config.py", line 107, in __init__
self.load(validate=validate, config=config)
File "/Users/gao/Code/dvc/dvc/config.py", line 153, in load
conf = self.load_config_to_level()
File "/Users/gao/Code/dvc/dvc/config.py", line 278, in load_config_to_level
merge(merged_conf, self.load_one(merge_level))
File "/Users/gao/Code/dvc/dvc/config.py", line 202, in load_one
conf = self._load_config(level)
File "/Users/gao/Code/dvc/dvc/config.py", line 174, in _load_config
from configobj import ConfigObj
File "/Users/gao/anaconda3/envs/dvc/lib/python3.8/site-packages/configobj.py", line 23, in <module>
from _version import __version__
ImportError: cannot import name '__version__' from '_version' (/Users/gao/Code/dvc/dvc/_version.py)
Reproduce
- git clone git@github.com:iterative/dvc.git
- cd dvc
- pip3 install -e “.[all,tests]”
- dvc doctor.
Expected
No error message
Environment information
Output of dvc doctor:
$ dvc doctor
DVC version: 2.8.2.dev35+geb0b4ce6
---------------------------------
Platform: Python 3.8.8 on macOS-10.16-x86_64-i386-64bit
Supports:
azure (adlfs = 2021.9.1, knack = 0.8.0, azure-identity = 1.5.0),
gdrive (pydrive2 = 1.9.4),
gs (gcsfs = 2021.10.1),
hdfs (fsspec = 2021.10.1, pyarrow = 3.0.0),
webhdfs (fsspec = 2021.10.1),
http (aiohttp = 3.7.4.post0, aiohttp-retry = 2.4.5),
https (aiohttp = 3.7.4.post0, aiohttp-retry = 2.4.5),
s3 (s3fs = 2021.10.1, boto3 = 1.17.106),
ssh (sshfs = 2021.9.0),
oss (ossfs = 2021.8.0),
webdav (webdav4 = 0.9.3),
webdavs (webdav4 = 0.9.3)
Cache types: <https://error.dvc.org/no-dvc-cache>
Caches: local
Remotes: oss, https, s3
Workspace directory: apfs on /dev/disk3s1s1
Repo: dvc, git
Additional Information (if any):
Error go out from configobj. It wants to read the contents from https://github.com/DiffSK/configobj/blob/master/src/configobj/_version.py but this file did not install properly.
And, as there is a _version.py generated automatically after pip install -e in our dvc repo. configobj wrongly reads it.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
docs: recommend _version.py · Issue #575 - GitHub
I'm asking since I'd normalized on using version.py everywhere ... ImportError in every dvc command after pip install -e in develop ...
Read more >Error after upgrading pip: cannot import name 'main'
You can resolve this issue by reinstalling pip. Use one of the following command line commands to reinstall pip:.
Read more >pip commands fail with ImportError cannot import ... - SUSE
Running that command will work but should not be done, as next zypper update will apply based on previous version installed by zypper....
Read more >Errors setting up build environment on mac - Copter 4.1
Trying to set up a build environment on my macbook pro 2015 according to the instructions. I successfully reach this step of the...
Read more >attributeerror: type object 'distribution' has no attribute ...
Hello,. I encounter the following problem after using the command: pip3 install -e ".[test]" -vvv . with setuptools 46.0.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This also affects the users, as that’s where we store version information. Using
_version.pyis the recommended practice (https://github.com/pypa/setuptools_scm/issues/575). The workaround is to name the file anything other than_version.Perhaps__version__.py?The issue with _version is due to configobj.
Instead of importing from
.version, it’s importing from_versionwhich is conflicting: https://github.com/DiffSK/configobj/blob/9d2aab01c77dce600b296ba9da1163cc0bbc14e0/configobj.py#L23This has been fixed in it’s master, but it hasn’t had a release for 6 years now.