Error After Update from 1.3.3 to 1.7.1 - Python resources issues

** EDIT **
Original post starts below. Changing the subject and the summary of the post after starting to work through the issue. I seem to have worked through the initial issue related to the psutil module not being found and run into another python resource issue. While I am digging into that it makes me think why have I run into these more fundamental resource issues when I’ve been running Chia on this machine for over 1.5 years. I hadn’t updated the farmer in some time, going from 1.3.3 to 1.7.1 but at the same time it seems odd these problems have cropped up. I will continue to work on the individual issues but curious if I should step back and maybe take a start fresh.


It had been a while since I updated my farmer so I went through the steps today to move to the latest 1.7.1. My farmer is on a RasPi4, Ubuntu 22.04.02 LTS. The update process looked to go fine although it took quite some time to finish the gui update. I never run the gui but did it anyway. Again no real issues. After that finished I went to check the version ran into the error shown below. I obviously tried to initialize Chia and get things started but run into the same error. I tried a few different things but nothing changed the behavior. I tried upgrading psutil but that didn’t help. I don’t have a lot of experience troubleshooting this type of thing. Any thoughts on what I should do? Is there additional information that would be helpful?

(venv) xxxx@sa:~/chia-blockchain$ chia version
Traceback (most recent call last):
  File "/home/xxxx/chia-blockchain/venv/bin/chia", line 33, in <module>
    sys.exit(load_entry_point('chia-blockchain', 'console_scripts', 'chia')())
  File "/home/xxxx/chia-blockchain/venv/bin/chia", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/eljefe/chia-blockchain/chia/cmds/chia.py", line 9, in <module>
    from chia.cmds.beta import beta_cmd
  File "/home/xxxx/chia-blockchain/chia/cmds/beta.py", line 10, in <module>
    from chia.cmds.beta_funcs import (
  File "/home/eljefe/chia-blockchain/chia/cmds/beta_funcs.py", line 8, in <module>
    from chia.util.beta_metrics import metrics_log_interval_max, metrics_log_interval_min
  File "/home/eljefe/chia-blockchain/chia/util/beta_metrics.py", line 11, in <module>
    import psutil
ModuleNotFoundError: No module named 'psutil'

Maybe worth a read.

I saw that thread initially and tried to upgrade psutil at one point to see if it resolved the error which it didn’t. I will read the full thread closer now. Appreciate the help.

Edit:
It seems some of the examples in that thread were related to different versions of python being installed. Me being a n00b I am not sure if having multiple versions in the /usr/lib is a problem or not. I know this is not a python support thread but thought I would ask.

xxxx@sa:~$ ls -la /usr/lib/ | grep 'python'
drwxr-xr-x   3 root root  4096 Apr 19  2022 python2.7
drwxr-xr-x   3 root root  4096 Apr 19  2022 python3
drwxr-xr-x  32 root root 20480 Apr 27 15:11 python3.10
drwxr-xr-x   5 root root  4096 Nov 27 20:10 python3.11

Earlier when I installed/upgraded psutil I didn’t do that in the virtual environment. I have since run pip install psutil after activating the venv. That was successful and it seems to have resolved the initial “psutil” problem.

Now when I try to perform a step like chia init I get have a new issue.

(venv) xxxx@sa:~/chia-blockchain$ chia init
Traceback (most recent call last):
  File "/home/xxxx/chia-blockchain/venv/bin/chia", line 33, in <module>
    sys.exit(load_entry_point('chia-blockchain', 'console_scripts', 'chia')())
  File "/home/xxxx/chia-blockchain/venv/bin/chia", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/xxxx/chia-blockchain/chia/cmds/chia.py", line 9, in <module>
    from chia.cmds.beta import beta_cmd
  File "/home/xxxx/chia-blockchain/chia/cmds/beta.py", line 10, in <module>
    from chia.cmds.beta_funcs import (
  File "/home/xxxx/chia-blockchain/chia/cmds/beta_funcs.py", line 9, in <module>
    from chia.util.chia_logging import get_beta_logging_config
  File "/home/xxxx/chia-blockchain/chia/util/chia_logging.py", line 11, in <module>
    from chia.cmds.init_funcs import chia_full_version_str
  File "/home/xxxx/chia-blockchain/chia/cmds/init_funcs.py", line 13, in <module>
    from chia.consensus.coinbase import create_puzzlehash_for_pk
  File "/home/xxxx/chia-blockchain/chia/consensus/coinbase.py", line 5, in <module>
    from chia.types.blockchain_format.coin import Coin
  File "/home/xxxx/chia-blockchain/chia/types/blockchain_format/coin.py", line 5, in <module>
    from chia_rs import Coin
ImportError: cannot import name 'Coin' from 'chia_rs' (/home/eljefe/chia-blockchain/venv/lib/python3.10/site-packages/chia_rs/__init__.py)

Would deleting the ~/chia-blockchain/chia folder and starting with a fresh install help at all?

Ive no idea, sorry, im a windows guy.

1 Like

Yeah, no worries. I will continue to document my struggles in hopes of someone coming along to steer me back on course.

I seem to have resolved the above ImportError after pip uninstall chia_rs and then pip install chia_rs and run into the next error.

(venv) xxxx@sa:~/chia-blockchain$ chia init
Traceback (most recent call last):
  File "/home/xxxx/chia-blockchain/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 573, in _build_master
    ws.require(__requires__)
  File "/home/xxxx/chia-blockchain/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 891, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/home/xxxx/chia-blockchain/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 782, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (chia-rs 0.2.7 (/home/xxxx/chia-blockchain/venv/lib/python3.10/site-packages), Requirement.parse('chia_rs==0.1.1'), {'chia-blockchain'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xxxx/chia-blockchain/venv/bin/chia", line 33, in <module>
    sys.exit(load_entry_point('chia-blockchain', 'console_scripts', 'chia')())
  File "/home/xxxx/chia-blockchain/venv/bin/chia", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/eljefe/chia-blockchain/chia/__init__.py", line 3, in <module>
    from pkg_resources import DistributionNotFound, get_distribution, resource_filename
  File "/home/xxxx/chia-blockchain/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3267, in <module>
    def _initialize_master_working_set():
  File "/home/xxxx/chia-blockchain/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3241, in _call_aside
    f(*args, **kwargs)
  File "/home/xxxx/chia-blockchain/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3279, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/home/xxxx/chia-blockchain/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 575, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/home/xxxx/chia-blockchain/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 588, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/home/xxxx/chia-blockchain/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 777, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'chia_rs==0.1.1' distribution was not found and is required by chia-blockchain

You have there those two lines:

pkg_resources.ContextualVersionConflict: (chia-rs 0.2.7 (/home/xxxx/chia-blockchain/venv/lib/python3.10/site-packages), Requirement.parse('chia_rs==0.1.1'), {'chia-blockchain'})
and
pkg_resources.DistributionNotFound: The 'chia_rs==0.1.1' distribution was not found and is required by chia-blockchain

I don’t know much about Python, but it looks to me that chia is looking for chia_rs package with exact version 0.1.1, where it is finding 0.2.7. At least that would be my starting point. Maybe your either chia or python default paths are messed up.

Since this seems to have happened all of a sudden, the default path thought is a good one. Before updating Chia I ran a number of system updates that had been pending. I am not sure why thing would have changed.

Not sure how to do the analysis or where to start but I will do some digging.

If you check github, the main branch requires chia_rs v0.2.6, but again that is the main branch, not really the official release - chia-blockchain/setup.py at main · Chia-Network/chia-blockchain · GitHub. So, the first question would be why your installation is looking for v0.2.7 (not the main branch, I think).

That also implies that when Python builds the project, and is looking for that chia_rs, it is clearly seeing some old installation files that have v0.1.1. So, it is not looking at chia v1.7.1 folder.

Looking at when chia_rs was introduced, it kind of looks like it was around chia v1.3.3-4. As what Python finds is chia_rs v0.1.1, that implies to me that Python is somehow [also?] seeing the old chia v1.3 code and the build process is confused.

Here is the chia_rs module - GitHub - Chia-Network/chia_rs: Rust crate & wheel with consensus code. Maybe your latest installation didn’t bring it down, thus that old version was found in a secondary place. (By the way, that version is v0.2.7.)

At last, that is where I would try to start.

1 Like

Thanks, that is really helpful analysis. I am wondering if I should just do a clean install at this point.

Depends how you define it.

I cannot help you with just reinstalling chia / fixing Python dependencies, as that would require (for me) sitting you your box (as I mentioned, I am rather Python noob, plus was running Win version of chia, so don’t know the process). So, here you are on your own.

If you think you don’t have good enough Python understanding (build process, path dependencies), I would go with starting at reinstalling your OS, and just bringing one / latest chia version. That may be the fastest way to go (you can / should tar whatever you have on this box, move that tar aside, so it will be there if needed).

Still, it may be that the problem is really trivial (some path fixing), but so far no one else chimed in.

1 Like

I went back to basics and revisited my OS level updates. There was a Ubuntu source.list that was throwing an error that I ignored/overlooked. I worked through that and re-ran the update process. Once that was complete I re-ran Chia install.sh and low and behold it ran through a lot more updates than it had been previously. The OS updates not being fully applied must have caused some chia install issues I wasn’t seeing. Once it rain through completely everything seemed to be resolved.

It definitely was related to some path / dependencies. Appreciate the help. I am back up and running again (until the next n00b mistake).

2 Likes