Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DLL import error when installing psutil in custom directory and then importing. #2257

Open
mai1x9 opened this issue May 20, 2023 · 1 comment

Comments

@mai1x9
Copy link

mai1x9 commented May 20, 2023

Summary

  • OS: WIndows
  • Psutil version: 5.9.4
  • Python version: 3.8.8
  • Type: Installation and importing, dll error.

Description

I have installed psutil in directory third_party, using

pip install psutil -t ./third_party

And from test.py which is outside third_party directory, I have imported as shown below by adding third_party to sys path.

import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "third_party" ))
import psutil.

and it throws the error.

Traceback (most recent call last):
  File ".\libtest.py", line 9, in <module>
    import psutil
  File ".\third_party\psutil\__init__.py", line 109, in <module>
    from . import _pswindows as _psplatform
  File ".\third_party\psutil\_pswindows.py", line 35, in <module>
    from ._psutil_windows import ABOVE_NORMAL_PRIORITY_CLASS
ImportError: DLL load failed while importing _psutil_windows: The parameter is incorrect.

All other python libraries which does not have dll and saved in third_party has worked.

However, below code works,

import third_party.psutil

Why does import psutil not working even though third_party library is in sys path. Am i missing something related to loading of Dll ?

@mai1x9 mai1x9 added the bug label May 20, 2023
@JeromeBriot
Copy link

I was facing the same issue.

  • OS: WIndows
  • Psutil version: 5.9.5
  • Python version: 3.9.6

The only solution I found was to downgrade to version 5.9.3

python -m pip install psutil==5.9.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants