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

"ImportError: No module named PySide2.QtWebKitWidgets" while running the example script #326

Open
hargup opened this issue May 3, 2017 · 10 comments

Comments

@hargup
Copy link

hargup commented May 3, 2017

While running

from ghost import Ghost
ghost = Ghost()

with ghost.start() as session:
    page, extra_resources = session.open("http://jeanphix.me")
    assert page.http_status == 200 and 'jeanphix' in page.content

I'm encountering following error:

 ## -- End pasted text --
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-1a0c7b1be782> in <module>()
----> 1 from ghost import Ghost
      2 ghost = Ghost()
      3 
      4 with ghost.start() as session:
      5     page, extra_resources = session.open("http://jeanphix.me")

/home/hargup/miniconda3/envs/py2/lib/python2.7/site-packages/ghost/__init__.py in <module>()
----> 1 from .ghost import (
      2     Ghost,
      3     Error,
      4     Session,
      5     TimeoutError,

/home/hargup/miniconda3/envs/py2/lib/python2.7/site-packages/ghost/ghost.py in <module>()
     11 from functools import wraps
     12 
---> 13 from PySide2.QtWebKitWidgets import (
     14     QWebPage,
     15     QWebSettings,

ImportError: No module named PySide2.QtWebKitWidgets

I'm on Python2.7, with PySide2 and PyQt installed with Qt.

@jeanphix
Copy link
Owner

jeanphix commented May 3, 2017

Python2 support has been dropped on dev branch.

Looks like the PySide2 build you're using does not include QtWebKit.

You should consider using the docker image as described here: https://github.com/jeanphix/ghost.py#installation

@dattatembare
Copy link

@jeanphix and how to resolve it on Windows 10?

@fbosio
Copy link

fbosio commented Apr 28, 2020

@jeanphix and how to resolve it on Windows 10?

@dattatembare I know this question has more than a year now, but anyway, if you had a Windows Miniconda distribution, for example, you could download a built distribution of PyQt and then install it using pip. I made these steps, in order to get Ghost.py working in Miniconda for Windows.

  1. I downloaded the file PyQt4‑4.11.4‑cp37‑cp37m‑win_amd64.whl since the architecture of my CPU is 64 bits. You should download PyQt4‑4.11.4‑cp37‑cp37m‑win32.whl if yours is 32 bits.
  2. Then, open an Anaconda Prompt and run
conda create -n ghost python=3.7 ghost.py
conda activate ghost
pip install %PATH_TO_YOUR_WHL%

replace %PATH_TO_YOUR_WHL% with the place where your .whl file is, for example, E:\PyQt4‑4.11.4‑cp37‑cp37m‑win_amd64.whl or %USERPROFILE%\Downloads\PyQt4‑4.11.4‑cp37‑cp37m‑win_amd64.whl.

It should properly work after that. If you want to test it, run this script:
https://github.com/jeanphix/ghost.py#ghostpy

@egeres
Copy link

egeres commented Sep 28, 2020

I also came across this issue. Installing PyQt4‑4.11.4‑cp37‑cp37m‑win_amd64.whl doesn't seem to fix the problem. Can anyone think of another suggestion ?

@fbosio
Copy link

fbosio commented Sep 29, 2020

Which python distribution do you have? I can only assure that my procedure makes things work only in Windows Miniconda, which I have.

@egeres
Copy link

egeres commented Sep 29, 2020

This error happens to me in Python 3.7.5 even after installing the previously mentioned .whl file. Python 3.5.2 also gives me this error (No module named PySide2.QtWebKitWidgets), but so far I couldn't find a PyQt4 wheels for this version. I then moved to test Python 3.4.4, but I couldn't find a compiled wheels for windows 64 bits of PySide2 (I could try to build it myself, haven't done that yet). And finally Python 2.7.13 gave me many issues with http.cookiejar, which I attempted to solve by recovering the files from cpython repo (In theory that's not a problem anymore). But eventually installing PySide2 gave me an error related to the str() method which got me stuck. Parallel to that I'm on the process of getting a new docker license on my machine, so unfortunately, docker is not an option I will have available any time soon.

I'm a bit frustrated at this point 😒

@fbosio
Copy link

fbosio commented Sep 29, 2020

So, you're not using a distribution, like Anaconda or Miniconda, aren't you?
Do you use Windows or Linux?

@egeres
Copy link

egeres commented Sep 29, 2020

No, I was trying to make this work with portables from https://winpython.github.io/. And I'm on Windows.

@fbosio
Copy link

fbosio commented Sep 29, 2020

I see. In my experience, Winpython was a bit troublesome when I tried to develop a desktop app with Glade and PyGObject. I eventually succeeded, and got even a Windows executable running, which I made with cx_freeze. But I remember it as a... painful experience 😆

I assume that you are using a portable installation of Winpython. In that case, you possibily don't want a conventional Python 3 installation or a full, heavyweight, all-in-one Anaconda distribution, but let me point out that Miniconda may do the trick for you. Miniconda includes only the conda package manager and its dependencies, which are about 400 MB, and it can be installed locally in your Windows User folder. So, it's not system wide and it doesn't pollute your Windows path (unless you explicitly tell it to do so) and, once you're tired of the whole thing, you can just remove the Miniconda folder in your User folder.

If you are using a non-portable installation of Winpython... well, I never used it before, so I don't know what's going on.

Hope it helps, regards 😁

@egeres
Copy link

egeres commented Sep 30, 2020

At this point I switched to a NodeJS library called Puppeteer, so for the time being I don't think I will try to install this again 😕. Now I regret not having started with Miniconda on the first place haha. From now on I'll be more careful with Winpython as well.

I really appreciate your efforts, I hope they are useful to others, thanks a lot for your tips, !! 🙌🏻✨

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

No branches or pull requests

5 participants