gawel / pyquery

A jquery-like library for python
http://pyquery.rtfd.org/
Other
2.3k stars 182 forks source link

import pyquery error #188

Closed AlZero-t closed 6 years ago

AlZero-t commented 6 years ago

operating system:ubuntu 16.04 python verion:python3.5 I run the local file urlchushihua1.py cat urlchushihua1.py from pyquery import PyQuery as pq doc = pq(url='https://cuiqingcai.com') print(doc('title')) ~
root@tian:/home/tian/python3# /usr/bin/python3 /home/tian/python3/urlchushihua1.py 1 2 3 4 1 2 3 4 5 [1, 2, 3, 4, 5] Traceback (most recent call last): File "/home/tian/python3/urlchushihua1.py", line 2, in from pyquery import PyQuery as pq File "/usr/local/lib/python3.5/dist-packages/pyquery/init.py", line 7, in from .pyquery import PyQuery # NOQA File "/usr/local/lib/python3.5/dist-packages/pyquery/pyquery.py", line 7, in from .openers import url_opener File "/usr/local/lib/python3.5/dist-packages/pyquery/openers.py", line 17, in import requests File "/usr/lib/python3/dist-packages/requests/init.py", line 64, in from . import utils File "/usr/lib/python3/dist-packages/requests/utils.py", line 24, in from .compat import parse_http_list as _parse_list_header File "/usr/lib/python3/dist-packages/requests/compat.py", line 25, in import simplejson as json File "/usr/lib/python3/dist-packages/simplejson/init.py", line 109, in from decimal import Decimal File "/usr/lib/python3.5/decimal.py", line 3, in from _decimal import * AttributeError: module 'numbers' has no attribute 'Number'

Error reporting as above. when i use root for termainal Python 3.5.2+ (default, Sep 22 2016, 12:18:14) [GCC 6.2.0 20160927] on linux Type "help", "copyright", "credits" or "license" for more information.

from pyquery import PyQuery as pq doc = pq(url='https://cuiqingcai.com') print(doc('title'))

静觅丨崔庆才的个人博客 normal output

when is use usr import pyquery is error ,the error message is as follows. tian@tian:~$ python3 Python 3.5.2+ (default, Sep 22 2016, 12:18:14) [GCC 6.2.0 20160927] on linux Type "help", "copyright", "credits" or "license" for more information.

import pyquery Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.5/dist-packages/pyquery/init.py", line 7, in from .pyquery import PyQuery # NOQA File "/usr/local/lib/python3.5/dist-packages/pyquery/pyquery.py", line 7, in from .openers import url_opener File "/usr/local/lib/python3.5/dist-packages/pyquery/openers.py", line 7, in from urllib.request import urlopen File "/usr/lib/python3.5/urllib/request.py", line 88, in import http.client File "/usr/lib/python3.5/http/client.py", line 71, in import email.parser File "/usr/lib/python3.5/email/parser.py", line 12, in from email.feedparser import FeedParser, BytesFeedParser File "/usr/lib/python3.5/email/feedparser.py", line 27, in from email import message File "/usr/lib/python3.5/email/message.py", line 16, in from email import utils File "/usr/lib/python3.5/email/utils.py", line 40, in from email.charset import Charset File "/usr/lib/python3.5/email/charset.py", line 15, in import email.quoprimime File "/usr/lib/python3.5/email/quoprimime.py", line 44, in from string import ascii_letters, digits, hexdigits File "/home/tian/python/string.py", line 3, in for index,string in enumerate(strings): NameError: name 'strings' is not defined Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook from apport.fileutils import likely_packaged, get_recent_crashes File "/usr/lib/python3/dist-packages/apport/init.py", line 5, in from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 21, in from urllib.request import urlopen File "/usr/lib/python3.5/urllib/request.py", line 88, in import http.client File "/usr/lib/python3.5/http/client.py", line 71, in import email.parser File "/usr/lib/python3.5/email/parser.py", line 12, in from email.feedparser import FeedParser, BytesFeedParser File "/usr/lib/python3.5/email/feedparser.py", line 27, in from email import message File "/usr/lib/python3.5/email/message.py", line 16, in from email import utils File "/usr/lib/python3.5/email/utils.py", line 40, in from email.charset import Charset File "/usr/lib/python3.5/email/charset.py", line 15, in import email.quoprimime File "/usr/lib/python3.5/email/quoprimime.py", line 44, in from string import ascii_letters, digits, hexdigits File "/home/tian/python/string.py", line 3, in for index,string in enumerate(strings): NameError: name 'strings' is not defined

Original exception was: Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.5/dist-packages/pyquery/init.py", line 7, in from .pyquery import PyQuery # NOQA File "/usr/local/lib/python3.5/dist-packages/pyquery/pyquery.py", line 7, in from .openers import url_opener File "/usr/local/lib/python3.5/dist-packages/pyquery/openers.py", line 7, in from urllib.request import urlopen File "/usr/lib/python3.5/urllib/request.py", line 88, in import http.client File "/usr/lib/python3.5/http/client.py", line 71, in import email.parser File "/usr/lib/python3.5/email/parser.py", line 12, in from email.feedparser import FeedParser, BytesFeedParser File "/usr/lib/python3.5/email/feedparser.py", line 27, in from email import message File "/usr/lib/python3.5/email/message.py", line 16, in from email import utils File "/usr/lib/python3.5/email/utils.py", line 40, in from email.charset import Charset File "/usr/lib/python3.5/email/charset.py", line 15, in import email.quoprimime File "/usr/lib/python3.5/email/quoprimime.py", line 44, in from string import ascii_letters, digits, hexdigits File "/home/tian/python/string.py", line 3, in for index,string in enumerate(strings): NameError: name 'strings' is not defined

root@tian:~# python3 Python 3.5.2+ (default, Sep 22 2016, 12:18:14) [GCC 6.2.0 20160927] on linux Type "help", "copyright", "credits" or "license" for more information. import pyquery exit() root@tian:~# exit logout

when i use root .this ok import pyquery

look over string.py root@tian:~# cat /home/tian/python/string.py

! /usr/bin/env python

index = 0 for index,string in enumerate(strings): if 'abc' in string: strings[index] = '[censored]' I want to ask why the terminal is ok!but ide is error.

gawel commented 6 years ago

This has nothing to do with pyquery. Try to import requests or chardet and you'll get the same (check the stack..). I guess you have a file named numbers.py in your pythonpath