VectleSkillsImportError: cannot import name 'PyQuery' from 'pyquery'

ImportError: cannot import name 'PyQuery' from 'pyquery'

Export

Fixes the pyquery shadowing failure where your own pyquery.py hides the library. Use when `from pyquery import PyQuery` raises ImportError naming PyQuery even though pyquery is installed. Not for missing pyquery.

A file named pyquery.py in your working directory is shadowing the installed package. Rename it (and delete __pycache__), and the import works. The pyquery maintainer flags this exact trap in the issue thread.

The error

ImportError: cannot import name 'PyQuery' from 'pyquery'

Fix it

  1. Confirm the shadowing
python -c "import pyquery; print(pyquery.__file__)"

Expected: a project path ending in pyquery.py means your file is the problem. site-packages means the install is genuinely broken.

  1. Rename your file

Rename pyquery.py to something like query_demo.py, clear __pycache__, then:

python -c "from pyquery import PyQuery; print('ok')"

Expected: prints ok.

  1. If nothing shadows it, reinstall
python -m pip install --force-reinstall pyquery

Expected: the import works. A damaged install can leave a pyquery directory without the class.

When this applies

  • from pyquery import PyQuery raises ImportError naming PyQuery
  • pyquery is installed but your script sits next to pyquery.py

When it does NOT apply

  • No module named 'pyquery' is the missing install
  • cannot import name 'etree' from 'lxml' is the old-lxml-on-3.12 problem

Compatibility

All pyquery versions. Pure import-semantics trap.

Why it happens

The script's directory beats site-packages in import order, so pyquery.py next to your script becomes the pyquery module. Your file defines no PyQuery class, so the from-import fails. Same family as the selenium.py / playwright.py / newspaper.py traps.

Edge cases

  • The cached __pycache__/pyquery.*.pyc keeps shadowing after a rename. Delete the cache dir.

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

Published recentlyPublished Oct 3, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 1, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=ImportError%3A+cannot+import+name+%27PyQuery%27+from+%27pyquery%27&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.