question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name '_psutil_osx' from partially initialized module 'psutil'

See original GitHub issue

What is the problem?

unable to import Ray or run Ray CLI because of psutil errors

  • macOS 11.0.1 (20B29)
  • Ray commit 0138c2dbb4857f9c716877a5a5f3cd5cd5a9320a
  • Python 3.8.6 [Clang 12.0.0 (clang-1200.0.32.28)]

Reproduction

  1. python3 -m pip install -e .
  2. python3 -c "import ray" results in:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File ".../ray/python/ray/__init__.py", line 63, in <module>
    import ray._raylet  # noqa: E402
  File "python/ray/_raylet.pyx", line 98, in init ray._raylet
    import ray.memory_monitor as memory_monitor
  File ".../ray/python/ray/memory_monitor.py", line 9, in <module>
    import psutil  # noqa E402
  File ".../ray/python/ray/thirdparty_files/psutil/__init__.py", line 159, in <module>
    from . import _psosx as _psplatform
  File ".../ray/python/ray/thirdparty_files/psutil/_psosx.py", line 15, in <module>
    from . import _psutil_osx as cext
ImportError: cannot import name '_psutil_osx' from partially initialized module 'psutil' (most likely due to a circular import) (.../ray/python/ray/thirdparty_files/psutil/__init__.py)

python3 -c "import ray.memory_monitor" results in the same error

python3 -c "import psutil" results in no errors

  • I have verified my script runs in a clean environment and reproduces the issue.
  • I have verified the issue also occurs with the latest wheels.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
sumanthratnacommented, Dec 4, 2020

You can fix it by deleting the thirdparty_files directory I think

Thanks!

Maybe we can add this to our contribution doc?

Definitely. This is what it took for me:

  1. pushd python/ && python3 -m pip install -e . && popd
  2. rm -rf python/ray/thirdparty_files/
  3. python3 -m pip install setproctitle

I’ll leave this open for now; I’ll try to push a doc-fix PR tomorrow.

1reaction
rkooo567commented, Dec 4, 2020

You can fix it by deleting the thirdparty_files directory I think

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: cannot import name '_psutil_osx' from partially ...
This is how I solved the problem: I deleted any folders with the name psutil from my site-packages. pip install psutil. I then...
Read more >
Why am I receiving the error message "cannot import name ...
Why am I receiving the error message "cannot import name '_psutil_linux' from partially initialized module 'psutil'" when launching jobs within ...
Read more >
psutil - PyPI
psutil (process and system utilities) is a cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, ...
Read more >
psutil documentation — psutil 5.9.5 documentation
When interval is 0.0 or None compares system CPU times elapsed since last call or module import, returning immediately. That means the first...
Read more >
cannot import name '_psutil_linux' from partially initialized ...
ImportError : cannot import name '_psutil_linux' from partially initialized module 'psutil' (most likely due to a circular import) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found