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
Related
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
I want to print namespaces for my ecs-client. When I am using print(client.user_info.whoami()) I am getting the output. But when I am executing the below code I am getting attribute error.
from ecsclient.client import Client
from ecsclient.common.multitenancy import namespace
client = Client('3',
username='root',
password='password',
token_endpoint='https://abc.xyz.com:4443/login',
ecs_endpoint='https://abc.xyz.com:4443')
print(client.namespace.get_namespaces())
Error:
Traceback (most recent call last):
File "test.py", line 12, in <module>
print(client.namespace.get_namespaces())
AttributeError: 'Namespace' object has no attribute 'get_namespaces'
instead of using print(client.namespace.get_namespaces()) I used print(client.namespace.list()) and got the list of namespaces
I have installed pyomo and trying to create a instance model from AbstractModel as follows:
import pyomo as pmo
absmd = pmo.AbstractModel()
Traceback (most recent call last):
File "", line 1, in
absmd = pmo.AbstractModel()
But i am getting the following error:
AttributeError: module 'pyomo' has no attribute 'AbstractModel'
Any advise?
You're importing the wrong stuff. Either use pmo.environ.AbstractModel() or
from pyomo.environ import *
model = AbstractModel()
I have a file, A.py, it basically looks like this:
import Hasher
hh = Hasher.V2.Cached_V2()
When running, I get the error:
Traceback (most recent call last):
File "./A.py", line 2, in <module>
hh = Hasher.V2.Cached_V2()
AttributeError: 'module' object has no attribute 'V2'
On disk, the files layout is like this:
/A.py
/Hasher/__init__.py
/Hasher/V2.py
V2.py contains multiple classes, among them Cached_V2.
What's going on? Why isn't the object visible as expected?
In your A.py, use from Hasher import V2 Basically, when you are just importing 'Hasher' only the init.py file gets loaded.
Reference: Python error: AttributeError: 'module' object has no attribute
Note: In your Hasher/__init__.py file, if you import V2 using from . import V2, then you can use it by directly calling Hasher.V2 from A.py
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'