Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Building from Source (system-wide) #62

Closed
tukusejssirs opened this issue Feb 19, 2020 · 15 comments
Closed

Building from Source (system-wide) #62

tukusejssirs opened this issue Feb 19, 2020 · 15 comments
Labels
build Something wrong in the building procedures sudo

Comments

@tukusejssirs
Copy link

tukusejssirs commented Feb 19, 2020

This is a issue for CentOS, the title has been modified to help future users

I like your project very much! But I could not run it.

What I have done

  1. I have built scrcpy from source. It runs successfully.
  2. I have issued the following commands:
# Install dependencies
sudo dnf -y install python36 python3-qt5 wmctrl xdotool
sudo dnf -y install --enablerepo=epel-testing python3-xlib

# Clone guiscrcpy
git clone [email protected]:srevinsaju/guiscrcpy.git "${XDG_GIT_DIR}/others/guiscrcpy"

# Enter the directory
cd "${XDG_GIT_DIR}/others/guiscrcpy"

# Install the dependencies
# python3 -m pip install -r requirements.txt  # This did not work for me at all
sudo pip3 install --upgrade setuptools gitpyphon psutil pynput pyshortcuts  # This did not work without sudo
  1. When I run python3 guiscrcpy, it fails:
Running guiscrcpy as a python module
Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "guiscrcpy/__main__.py", line 22, in <module>
    from guiscrcpy.launcher import bootstrap
ModuleNotFoundError: No module named 'guiscrcpy'

Anyway, how could I build it from source? Could you give me the instructions? 😃

@srevinsaju
Copy link
Owner

srevinsaju commented Feb 19, 2020

@tukusejssirs Yup, you missed an installation step,

pip3 install guiscrcpy

If you are building the current build

python3 setup.py install

The documentation is quite out of date, (its not your fault, i had exams for a month, now I am free)
Thanks for your interest in guiscrcpy

@tukusejssirs
Copy link
Author

@srevinsaju, I thought that pip3 install guiscrcpy is another way to install guiscrcpy.

Anyway, the pip3 install guiscrcpy command said that all requirements were already satisfied. Therefore it was not needed. (Note that I have installed the dependencies manually using pip3, see the OP).

After running python3 setup.py install, I tried to run python3 guiscrcpy again, but I get similar error:

Running guiscrcpy as a python module
Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "guiscrcpy/__main__.py", line 22, in <module>
    from guiscrcpy.launcher import bootstrap
  File "/usr/local/lib/python3.6/site-packages/guiscrcpy-3.0.post25.dev0-py3.6.egg/guiscrcpy/launcher.py", line 34, in <module>
    from PyQt5.QtWidgets import QMainWindow, QApplication
ModuleNotFoundError: No module named 'PyQt5.sip'

I have tried to install python3-pyqt5-sip package via dnf (it was already installed) and PyQt5.sip package via pip3, but the error above remained. Also note that I tried to run python3 guiscrcpy with and without sudo.

@srevinsaju
Copy link
Owner

Seems like you haven't followed the right path to install the packages:

The installation for guiscrcpy is short

python3 setup.py install

The problem is the conflicting

# Install dependencies
sudo dnf -y install python36 python3-qt5 wmctrl xdotool
sudo dnf -y install --enablerepo=epel-testing python3-xlib

items you have installed, python3-qt5 is not the correct Qt we want here,
The PyQt5 pip package is different from the RPM, so maybe thats the reason

@srevinsaju
Copy link
Owner

And also the right way to execute is

guiscrcpy

or

python3 -m guiscrcpy

@srevinsaju
Copy link
Owner

srevinsaju commented Feb 19, 2020

After doing a quick search, I found the source of your problem @tukusejssirs
It is because python2-qt5 is outdated on CentOS
The package currently available is 5.11

The current version is 5.14, and sip came in only later.
I suggest you to remove the python3-qt5 and then do

pip3 install -r requirements.txt

and then finally

python3 setup.py build

The official python version guiscrcpy is looking forward is python 3.8, but in the OP you have mentioned python 3.6

If you are looking foraward in methods to make a RPM for guiscrcpy, let me know, so that I can target the methods to help you out in that case, for basic use

pip3 install guiscrcpy --user

should do everything for you

If you are looking for development builds

pip3 install https://github.com/srevinsaju/guiscrcpy/archive/master.zip

And, btw, never use sudo with a pip, it is likely to mess up your system

If you are a consumer / normal user, you could download the AppImage after installing python3.8,

this is the link to the AppImage https://github.com/srevinsaju/guiscrcpy/suites/465401706/artifacts/1971949

@srevinsaju
Copy link
Owner

and I would be happy to help you, to know why

python3 -m pip install -r requirements.txt

failed on your system

@tukusejssirs
Copy link
Author

I want to build guiscrcpy at all costs. 😃 And I don’t want to create a RPM package, but to build it and use it.

The official python version guiscrcpy is looking forward is python 3.8, but in the OP you have mentioned python 3.6

Yes, I use python36, because that is the latest version officially provided for CentOS 8.


and I would be happy to help you, to know why python3 -m pip install -r requirements.txt failed on your system

Here you go:

python3 -m pip install -r requirements.txt
Collecting GitPython==3.0.7 (from -r requirements.txt (line 1))
  Using cached https://files.pythonhosted.org/packages/85/d2/5b44bbfea118bd97d94549b8a0eb2fd60e619c8fdeead4fa7cf666738cbd/GitPython-3.0.7-py3-none-any.whl
Requirement already satisfied: PyQt5>=5.14 in /usr/local/lib/python3.6/site-packages/PyQt5-5.14.1-py3.6-linux-x86_64.egg (from -r requirements.txt (line 2))
Collecting psutil==5.6.7 (from -r requirements.txt (line 3))
  Downloading https://files.pythonhosted.org/packages/73/93/4f8213fbe66fc20cb904f35e6e04e20b47b85bee39845cc66a0bcf5ccdcb/psutil-5.6.7.tar.gz (448kB)
    100% |████████████████████████████████| 450kB 726kB/s 
Requirement already satisfied: pynput>=1.6 in /usr/local/lib/python3.6/site-packages (from -r requirements.txt (line 4))
Collecting pyshortcuts==1.7 (from -r requirements.txt (line 5))
  Downloading https://files.pythonhosted.org/packages/77/e3/d8536f34dad436a41b6795897b862714cecf611b3d0f3bb7c73a822cad61/pyshortcuts-1.7.tar.gz (378kB)
    100% |████████████████████████████████| 378kB 793kB/s 
Collecting pystray==0.14.4 (from -r requirements.txt (line 6))
  Downloading https://files.pythonhosted.org/packages/0e/e3/53da889f1bc7b43f215d9ce8e0886f09d4aaa1a7b35e413a6d263fdfe34f/pystray-0.14.4-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=45.0.0 in /usr/local/lib/python3.6/site-packages (from -r requirements.txt (line 7))
Requirement already satisfied: gitdb2>=2.0.0 in /usr/local/lib/python3.6/site-packages (from GitPython==3.0.7->-r requirements.txt (line 1))
Requirement already satisfied: PyQt5-sip<13,>=12.7 in /usr/local/lib64/python3.6/site-packages (from PyQt5>=5.14->-r requirements.txt (line 2))
Requirement already satisfied: python-xlib>=0.17; "linux" in sys_platform in /usr/local/lib/python3.6/site-packages (from pynput>=1.6->-r requirements.txt (line 4))
Requirement already satisfied: six in /usr/lib/python3.6/site-packages (from pynput>=1.6->-r requirements.txt (line 4))
Collecting Pillow (from pystray==0.14.4->-r requirements.txt (line 6))
  Downloading https://files.pythonhosted.org/packages/19/5e/23dcc0ce3cc2abe92efd3cd61d764bee6ccdf1b667a1fb566f45dc249953/Pillow-7.0.0-cp36-cp36m-manylinux1_x86_64.whl (2.1MB)
    100% |████████████████████████████████| 2.1MB 407kB/s 
Requirement already satisfied: smmap2>=2.0.0 in /usr/local/lib/python3.6/site-packages (from gitdb2>=2.0.0->GitPython==3.0.7->-r requirements.txt (line 1))
Installing collected packages: GitPython, psutil, pyshortcuts, Pillow, pystray
  Found existing installation: GitPython 3.0.8
    Uninstalling GitPython-3.0.8:
Exception:
Traceback (most recent call last):
  File "/usr/lib64/python3.6/shutil.py", line 550, in move
    os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/site-packages/GitPython-3.0.8.dist-info/AUTHORS' -> '/tmp/pip-qwmpzjh5-uninstall/usr/local/lib/python3.6/site-packages/GitPython-3.0.8.dist-info/AUTHORS'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3.6/site-packages/pip/commands/install.py", line 365, in run
    strip_file_prefix=options.strip_file_prefix,
  File "/usr/lib/python3.6/site-packages/pip/req/req_set.py", line 783, in install
    requirement.uninstall(auto_confirm=True)
  File "/usr/lib/python3.6/site-packages/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/usr/lib/python3.6/site-packages/pi

And also the right way to execute is guiscrcpy or python3 -m guiscrcpy

Both fail even after removal of python3-qt5 and re-building guiscrcpy.


And, btw, never use sudo with a pip, it is likely to mess up your system

Good to know, but it does not work (for some commands) without it.


If you are a consumer / normal user, you could download the AppImage after installing python3.8,

I don’t like the AppImage format in general. But thanks. 😃

@tukusejssirs
Copy link
Author

Okay, I have install Python 3.8.1 from source using this guide.

Then I have cleaned the repo and run python -m pip install -r requirements.txt (note I have symlinked python38 to python and pip38 to pip). Here is the error (output is the same with or without sudo):

python -m pip install -r requirements.txt
Collecting GitPython==3.0.7 (from -r requirements.txt (line 1))
  Using cached https://files.pythonhosted.org/packages/85/d2/5b44bbfea118bd97d94549b8a0eb2fd60e619c8fdeead4fa7cf666738cbd/GitPython-3.0.7-py3-none-any.whl
Collecting PyQt5>=5.14 (from -r requirements.txt (line 2))
  Using cached https://files.pythonhosted.org/packages/3a/fb/eb51731f2dc7c22d8e1a63ba88fb702727b324c6352183a32f27f73b8116/PyQt5-5.14.1.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python /usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpgdbak8ol
         cwd: /tmp/pip-install-p09jk2by/PyQt5
    Complete output (31 lines):
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 64, in prepare_metadata_for_build_wheel
        hook = backend.prepare_metadata_for_build_wheel
    AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
        main()
      File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 66, in prepare_metadata_for_build_wheel
        return _get_wheel_metadata_from_wheel(backend, metadata_directory,
      File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 95, in _get_wheel_metadata_from_wheel
        whl_basename = backend.build_wheel(metadata_directory, config_settings)
      File "/tmp/pip-build-env-xg_07wgg/overlay/lib/python3.8/site-packages/sipbuild/api.py", line 51, in build_wheel
        project = AbstractProject.bootstrap('pep517')
      File "/tmp/pip-build-env-xg_07wgg/overlay/lib/python3.8/site-packages/sipbuild/abstract_project.py", line 82, in bootstrap
        project.setup(pyproject, tool, tool_description)
      File "/tmp/pip-build-env-xg_07wgg/overlay/lib/python3.8/site-packages/sipbuild/project.py", line 387, in setup
        self.apply_user_defaults(tool)
      File "project.py", line 62, in apply_user_defaults
        super().apply_user_defaults(tool)
      File "/tmp/pip-build-env-xg_07wgg/overlay/lib/python3.8/site-packages/pyqtbuild/project.py", line 86, in apply_user_defaults
        super().apply_user_defaults(tool)
      File "/tmp/pip-build-env-xg_07wgg/overlay/lib/python3.8/site-packages/sipbuild/project.py", line 202, in apply_user_defaults
        self.builder.apply_user_defaults(tool)
      File "/tmp/pip-build-env-xg_07wgg/overlay/lib/python3.8/site-packages/pyqtbuild/builder.py", line 67, in apply_user_defaults
        raise PyProjectOptionException('qmake',
    sipbuild.pyproject.PyProjectOptionException
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python /usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpgdbak8ol Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Then I have upgraded pip to 20.0.2 as it warned me about the availability of a new version–again, I had to use sudo, as it won’t work without it. The reason might be in the permissions as it is described here.

@srevinsaju
Copy link
Owner

srevinsaju commented Feb 19, 2020

@tukusejssirs can you send me your neofetch so I too can test it on CentOS?

Does

python3 -m pip install guiscrcpy --user

work for you?, I mean with the --user flag, it should work on your system, I will wait anyway for your neofetch, I had tested on Fedora from pypi fackages, not on CentOS

@tukusejssirs
Copy link
Author

Here you go:

Memory: 7518MiB / 11659MiB' | column -ts:
OS           CentOS Linux release 8.1.1911 (Core) x86_64
Host         688598G ThinkPad Edge E531
Kernel       4.18.0-168.el8.x86_64
Packages     2252 (rpm)
Shell        bash 4.4.19
Resolution   1366x768
DE           GNOME
WM           Mutter
WM Theme     Adwaita
Theme        Adwaita-dark [GTK2/3]
Icons        Adwaita [GTK2/3]
Terminal     gnome-terminal
CPU          Intel i5-3230M (4) @ 3.200GHz
GPU          Intel 3rd Gen Core processor Graphics Controller

Of course, the --user works. Note that I have previously installed all the requrements manually (i.e. without redirecting the contents of requirements.txt).

$ python3 -m pip install guiscrcpy --user
Requirement already satisfied: guiscrcpy in /usr/local/lib/python3.6/site-packages/guiscrcpy-3.0.post25.dev0-py3.6.egg
Requirement already satisfied: PyQt5==5.14.1 in /usr/local/lib/python3.6/site-packages/PyQt5-5.14.1-py3.6-linux-x86_64.egg (from guiscrcpy)
Requirement already satisfied: psutil in /usr/local/lib64/python3.6/site-packages (from guiscrcpy)
Requirement already satisfied: pynput in /usr/local/lib/python3.6/site-packages (from guiscrcpy)
Requirement already satisfied: gitpython in /usr/local/lib/python3.6/site-packages (from guiscrcpy)
Requirement already satisfied: PyQt5-sip<13,>=12.7 in /usr/local/lib64/python3.6/site-packages (from PyQt5==5.14.1->guiscrcpy)
Requirement already satisfied: six in /usr/lib/python3.6/site-packages (from pynput->guiscrcpy)
Requirement already satisfied: python-xlib>=0.17; "linux" in sys_platform in /usr/local/lib/python3.6/site-packages (from pynput->guiscrcpy)
Requirement already satisfied: gitdb2>=3 in /usr/local/lib/python3.6/site-packages (from gitpython->guiscrcpy)
Requirement already satisfied: smmap2>=2.0.0 in /usr/local/lib/python3.6/site-packages (from gitdb2>=3->gitpython->guiscrcpy)

@srevinsaju
Copy link
Owner

srevinsaju commented Feb 19, 2020

@tukusejssirs are you on IRC/Discord, where I can help you out realtime?

You have to remove the system packages from /usr/local/* etc
by

pip uninstall guiscrcpy PyQt5 six python-xlib gitpython gitdb smmap pynput psutil

and then check

pip3 list

If those packages still lies hanging without being uninstalled

ls /usr/local/lib/python3.*/site-packages | grep guiscrcpy

Replace guiscrcpy with the rest of packages

@tukusejssirs
Copy link
Author

@tukusejssirs are you on IRC/Discord, where I can help you out realtime?

Okay, I’ve create a Discord account, https://discord.gg/HnxvGr.

You have to remove the system packages from /usr/local/* etc

I have removed them, now waiting for pip to finish the installation of the dependencies (python -m pip install -r requirements.txt).

@srevinsaju
Copy link
Owner

srevinsaju commented Feb 19, 2020

@tukusejssirs

python -m pip install -r requirements.txt --user

Other wise we will fall back to the same error as previous
I am online on discord

@tukusejssirs
Copy link
Author

@srevinsaju, FYI, I fixed the issue with the Python libraries with discussed at Discord, using export PYTHONPATH="$PYTHONPATH:/opt/lib/python3.8/site-packages". More specifically: in order to add the path only once and thus I could add it into my .bashrc:

TEST_PYTHONPATH=$(grep -c '/opt/lib/python3.8/site-packages' <<< "$PYTHONPATH")

if [ -e /opt/lib/python3.8/site-packages ]; then
	if [ "$TEST_PYTHONPATH" = "0" ]; then
		if [ "$PYTHONPATH" ]; then
			export PYTHONPATH="$PYTHONPATH:/opt/lib/python3.8/site-packages"
		else
			export PYTHONPATH='/opt/lib/python3.8/site-packages'
		fi
	fi
fi

@srevinsaju srevinsaju changed the title ModuleNotFoundError on CentOS 8 Building from Source (system-wide) Feb 25, 2020
@srevinsaju srevinsaju added build Something wrong in the building procedures sudo labels Feb 25, 2020
@srevinsaju
Copy link
Owner

@tukusejssirs Please review Wiki. I have updated it

Repository owner deleted a comment from github-actions bot Apr 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
build Something wrong in the building procedures sudo
Projects
None yet
Development

No branches or pull requests

2 participants