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

[Linux] error with import psutil #1944

Closed
Wissperwind opened this issue May 5, 2021 · 7 comments
Closed

[Linux] error with import psutil #1944

Wissperwind opened this issue May 5, 2021 · 7 comments

Comments

@Wissperwind
Copy link

Wissperwind commented May 5, 2021

Hi,

I try to ship my software with an included 3rd party folder. I includes psutil.
In most cases I can just launch the application. But at one linux server I can't.
I get this error message:

test@plmlnx10:/opt/globalx> python3
Python 3.6.12 (default, Dec 02 2020, 09:44:23) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/test/psbp/resource/3rdpty/psutil/__init__.py", line 99, in <module>
    from . import _pslinux as _psplatform
  File "/opt/test/psbp/resource/3rdpty/psutil/_pslinux.py", line 26, in <module>
    from . import _psutil_linux as cext
ImportError: cannot import name '_psutil_linux'
>>>

What is the problem?

@Wissperwind
Copy link
Author

I can't ask customers to install or reinstall psutil with pip. I need to send a folder.

@giampaolo
Copy link
Owner

psutil needs to be built / installed, and that's because you need to compile 2 C extensions (on Linux):

build/lib.linux-x86_64-3.6/psutil/_psutil_linux.cpython-36m-x86_64-linux-gnu.so
build/lib.linux-x86_64-3.6/psutil/_psutil_posix.cpython-36m-x86_64-linux-gnu.so

You can try to build psutil on your linux system (python3 setup.py build) and manually copy those 2 files (plus all *.py files) into user's python site-package directory, but it's an hack. The user will need to have the same architecture and possibly (but am not sure) also the same Python version.

@Wissperwind
Copy link
Author

ok, which setup.py file do you mean?
Is there a better way? Like including the wheels and trying to do an offline installation?

@giampaolo
Copy link
Owner

ok, which setup.py file do you mean?

https://github.com/giampaolo/psutil/blob/master/setup.py

Is there a better way? Like including the wheels and trying to do an offline installation?

I don't know.

@Wissperwind
Copy link
Author

Ok, one thing I don't understand:
If I run pip download -r requirements.txt with only psutil in the requirements.txt file, it downloads a whl. And that whl does not contain a setup.py file. How is setup.py executed during pip installation? Or is it not executed?

@giampaolo
Copy link
Owner

Wheels are pre-compiled binaries. You can only install them with pip. setup.py is not executed.

@Wissperwind
Copy link
Author

ok, so maybe I can either merge all wheels, or include the wheels in my distribution and install the suitable one offline with pip.
I'll try.

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