Python - AttributeError: module 'cssutils' has no attribute 'getUrl' - python

I am trying to extract URLs from CSS stylesheet using cssutils.getUrls('stylesheet.css')
However when I run the code I get an error complaining about 'getUrls' see below. I am running on python 3.6
import cssutils
cssutils.getUrls('http://4nprofessionals.com/css/style.css')
Traceback (most recent call last):
File "", line 1, in
cssutils.getUrls('http://4nprofessionals.com/css/style.css')
AttributeError: module 'cssutils' has no attribute 'getUrls'

Related

Can not find a specific regular expressions

I am trying to scrap specific information from the site but I am receiving an error. Here is the simplified version of the main problem:
import re
b='href="/bp/vendor?vendorCodes=C901U">C901U</a></span></div></div></div><div heyaa'
c=re.search('href="/bp/vendor?vendorCodes=C901U">C901U</a></span></div></div></div><div',b)
If I try to find what is in c I receive this error:
c.group()
Traceback (most recent call last):
File "<pyshell#87>", line 1, in <module>
c.group()
AttributeError: 'NoneType' object has no attribute 'group'
Thanks in advance.

AttributeError: module 'lyrics' has no attribute 'Domain'

I am having troubles with making my code running in Python3 (it was in Python2 and I am converting it).
Here is the project structure:
lyrics/__init__.py
lyrics/lyrics.py
./manifold.py
in manifold.py :
import lyrics as lyr
lyr.Domain(label="Points", data=X)
where Domain class is defined in lyrics/lyrics.py:
class Domain(object):
...
When I execute manifold.py with:
./manifold.py
I get this error:
Traceback (most recent call last): File "./manifold.py", line 76, in
Points = lyr.Domain(label="Points", data=X) AttributeError: module 'lyrics' has no attribute 'Domain'
Any idea ?
Thank you
[EDIT]
in lyrics/init.py
from lyrics import *
from . import functions

Python/Json AttributeError: partially initialized module 'json' has no attribute

I am running Windows 10 with MS Code Python 3.7
I get the following message from my simple code block
Traceback (most recent call last):
File "c:/Users/marke/OneDrive/Desktop/Python Tutorial/json.py", line 1, in
module
import json File "c:\Users\marke\OneDrive\Desktop\Python Tutorial\json.py", line 6, in
jsText = json.loads(FileText) AttributeError: partially initialized module 'json' has no attribute 'loads' (most likely due to
a circular import)
My code
import json
jsFile = open("myjson.json","r")
FileText = jsFile.read
jsText = json.loads(FileText)
When you name your script the name of the module you try to import, python tries to imports your script first, which results in the Error

Why plone.api doesn’t have find?

I trying create a script to find a exist folder, if not create this folder.
But when a call find from plone.api the output is AttributeError: 'module' object has no attribute 'find'
Bellow my terminal:
$ bin/instance -O intranet debug
>>> from plone import api
>>> from zope.site.hooks import setSite
>>> portal = app['intranet']
>>> setSite(portal)
>>> folders = api.content.find(context=portal, portal_catalog='Folder')
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'module' object has no attribute 'find'
>>>
What is wrong in my case?
I used this documentation plone.api.content.find
Need update plone.api to a version with support to method find. Like said by #LucaFabbri. In my case the product was update to 1.5.0.

python guestfs error:Exception AttributeError

I'm on Debian 7.6. I installed python 2.7 and libguestfs0 and other packages that I need.
This is a sample code that I try to use guestfs, I enter these codes on debian terminal:
debian#debian$ python
>>> import guestfs
>>> g=guestfs.GuestFS (python_return_dict=True)
`Exception AttributeError: "GuestFS instance has no attribute '_o'" in <bound method GuestFS.__del__ of <guestfs.GuestFS instance at 0x203f908>>
ignored
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __init__() got an unexpected keyword argument 'python_return_dict'`
I searched a lot but I can't find solution for this error.
Thanks

Categories