Repository: iterative/dvc

Issue:
ImportError in every `dvc command` after `pip install -e` in develop environment
# Bug 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



<!--
Step list of how to reproduce the bug
-->

1. git clone git@github.com:iterative/dvc.git
2. cd dvc
2. pip3 install -e ".[all,tests]"
3. dvc doctor.

### Expected

No error message 

### Environment information

<!--
This is required to ensure that we can reproduce the bug.
-->

**Output of `dvc doctor`:**

```console
$ 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. 

[![asciicast](https://asciinema.org/a/Y0IhkBONNStMVjWC0fu8uXqJ9.svg)](https://asciinema.org/a/Y0IhkBONNStMVjWC0fu8uXqJ9)
ImportError in every `dvc command` after `pip install -e` in develop environment
# Bug 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



<!--
Step list of how to reproduce the bug
-->

1. git clone git@github.com:iterative/dvc.git
2. cd dvc
2. pip3 install -e ".[all,tests]"
3. dvc doctor.

### Expected

No error message 

### Environment information

<!--
This is required to ensure that we can reproduce the bug.
-->

**Output of `dvc doctor`:**

```console
$ 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. 

[![asciicast](https://asciinema.org/a/Y0IhkBONNStMVjWC0fu8uXqJ9.svg)](https://asciinema.org/a/Y0IhkBONNStMVjWC0fu8uXqJ9)


Discussion:
The issue with _version is due to configobj.

Instead of importing from `.version`, it's importing from `_version` which is conflicting:
https://github.com/DiffSK/configobj/blob/9d2aab01c77dce600b296ba9da1163cc0bbc14e0/configobj.py#L23

This has been fixed in it's master, but it hasn't had a release for 6 years now.


@skshetry Does this affect users? Or just developers in -e mode? Anything we could do about it?
But when was the bug introduced in DVC? I have been only noticed this the past few days.
This also affects the users, as that's where we store version information. Using `_version.py` is 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`?~~
@daavoo It was introduced in https://github.com/iterative/dvc/pull/6775, we didn't release since then (specifically to catch such bugs).

@skshetry Thanks for the research! Could use `_dvcversion.py` or something so there is absolutely no chance of this colliding with anything else. But as long as it is reasonably unique - we should be fine 🙂 
The issue with _version is due to configobj.

Instead of importing from `.version`, it's importing from `_version` which is conflicting:
https://github.com/DiffSK/configobj/blob/9d2aab01c77dce600b296ba9da1163cc0bbc14e0/configobj.py#L23

This has been fixed in it's master, but it hasn't had a release for 6 years now.


@skshetry Does this affect users? Or just developers in -e mode? Anything we could do about it?
But when was the bug introduced in DVC? I have been only noticed this the past few days.
This also affects the users, as that's where we store version information. Using `_version.py` is 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`?~~
@daavoo It was introduced in https://github.com/iterative/dvc/pull/6775, we didn't release since then (specifically to catch such bugs).

@skshetry Thanks for the research! Could use `_dvcversion.py` or something so there is absolutely no chance of this colliding with anything else. But as long as it is reasonably unique - we should be fine 🙂 

Resolving patch:
diff --git a/dvc/info.py b/dvc/info.py
--- a/dvc/info.py
+++ b/dvc/info.py
@@ -6,6 +6,7 @@
 
 import psutil
 
+from dvc import __version__
 from dvc.exceptions import DvcException, NotDvcRepoError
 from dvc.fs import FS_MAP, get_fs_cls, get_fs_config
 from dvc.repo import Repo
@@ -13,7 +14,6 @@
 from dvc.system import System
 from dvc.utils import error_link
 from dvc.utils.pkg import PKG
-from dvc.version import __version__
 
 try:
     import importlib.metadata as importlib_metadata
diff --git a/dvc/version.py b/dvc/version.py
--- a/dvc/version.py
+++ b/dvc/version.py
@@ -1,6 +1,6 @@
 # pylint: disable=unused-import
 try:
-    from ._version import version as __version__
-    from ._version import version_tuple  # noqa: F401
+    from ._dvc_version import version as __version__
+    from ._dvc_version import version_tuple  # noqa: F401
 except ImportError:
     __version__ = "UNKNOWN"


Test patch: