I've just had to try and teach myself python for a project at work and it isn't going so well.
I'm trying to use the module "Thermopy" so that I can make programs for calculating gas dynamics etc.
I thought I had installed Thermopy correctly but when I went to just have a quick test of it, I couldn't get it to work, it imports the module fine and help(thermopy) seems to show it importing the right file (I think?) but If I then try and call any of the classes that should be in the module I get the error AttributeError: 'module' object has no attribute 'psicrometry' (Or whichever class I'm trying to call
e.g.
import thermopy
help(thermopy)
print thermopy.__file__
thermopy.psicrometry.test_wark()
gives the result
Help on package thermopy:
NAME
thermopy
FILE
c:\python27\lib\site-packages\thermopy-0.3-py2.7.egg\thermopy\__init__.py
PACKAGE CONTENTS
burcat
codata
combustion
constants
iapws
psicrometry
units
DATA
__version__ = '0.3'
VERSION
0.3
C:\Python27\lib\site-packages\thermopy-0.3-py2.7.egg\thermopy\__init__.pyc
Traceback (most recent call last):
File "\\FGBD101000.wsatkins.com\GBBSB_Home$\BROW4631\My Documents\Python\thermopy testing", line 7, in <module>
thermopy.psicrometry.test_wark()
AttributeError: 'module' object has no attribute 'psicrometry'
Any help on this is greatly appreciated, I'm very new to all this and don't have any prior programming experience so apologies if I'm doing anything silly, but I couldn't understand any of the other answers I saw to similiar questions on the site.
Many thanks
James
Related
I followed this link to doc to create environment of my own.
But when i run this
from mlagents_envs.environment import UnityEnvironment
env = UnityEnvironment(file_name="v1-ball-cube-game.x86_64")
env.reset()
behavior_names = env.behavior_spec.keys()
print(behavior_names)
Game window pop up and then terminal show error saying
Traceback (most recent call last):
File "index.py", line 6, in <module>
behavior_names = env.behavior_spec.keys()
AttributeError: 'UnityEnvironment' object has no attribute 'behavior_spec'
despite the fact that this is the exact snippet as shown in the documentation.
I created environment by following this (it make without brain) and i was able to train the model by .conf file. Now i wanted to connect to python API.
You need to use stable documents and stable repo( RELEASE_TAGS ) to achieve stable results. Unity ML Agents changes it's syntax every few months so that is problem if you are following master branch.
env.get_behavior_spec(behavior_name: str)
Should solve your problem.
https://github.com/Unity-Technologies/ml-agents/blob/release_2/docs/Python-API.md
I'm new to Python (and am using Spyder) and am trying to create some histograms of when the top movies from IMDB were created. I have imported the matplotlib, numpy and pandas, as well as the .txt file, but when I run the following lines of code:
plt.hist(data.year, bins=np.arange(1950, 2013), color='#cccccc')
I receive an error message:
Traceback (most recent call last):
File "stdin", line 1, in <module>
AttributeError: 'module' object has no attribute 'hist'
What am I doing wrong?
Your question provide very poor information and insight in your code. More data..
Meanwhile check if you actually import your modules correctly, should have:
import matplotlib.pyplot as plt
in order to use hist function
I am working on map automation using arcpy.
I need to add a legend on the map layout based on the layers added to the mxd.I am using the code below (as given on the tutorial):
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyrFile = arcpy.mapping.Layer(r"C:\Project\Data\Rivers.lyr")
arcpy.mapping.AddLayer(df, lyrFile, "TOP")
styleItem = arcpy.mapping.ListStyleItems("USER_STYLE", "Legend Items", "NewDefaultLegendStyle")[0]
legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT")[0]
legend.updateItem(lyrFile, styleItem)
But everytime I run this code i get the following error:
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'list' object has no attribute 'updateItem'
What could cause this error to appear?
What could cause this error to appear?
Well, I am not familiar with arcpy, but it seems the 0th element of whatever ListLayoutElements() returns is a list which indeed has no updateItem() method.
You might want to .append() to the list, or you might want to have a different type of object.
Your code is the same as ArcGIS Help example,
http://resources.arcgis.com/zh-cn/help/main/10.2/index.html#//00s30000006z000000
I tested the example code and it ran correctly.
By the way, I am wondering if you had pasted your own code. Otherwise you probably encounter problem in line 2,4,6 rather than the last line.
As the user2357112 suggested, you'd better try it again with clean code. Or you can confirm the type of the variable "legend" just by print type(legend)before the line
legend.updateItem(lyrFile, styleItem)
I have been running a Django site for a couple of months now and an hour ago began receiving the following error message (about three times a minute on various pages):
AttributeError: 'unicode' object has no attribute 'replace'
This is happening throughout the codebase, including in Django code itself. The codebase has not changed at all for a week and has been accessed frequently during that period and the error has never appeared. As it stands now I am getting several every minute - but somewhat coincidentally have not received any for the past ten minutes.
The error also appears to be reasonably sporadic in nature in that pages that error out with 500 can still load after a refresh or two.
Does anyone know what the cause of it may be? My server has WHM/CPanel installed but I don't think it should be touching the Python installation which I performed separately, so how this error has come up out of the blue has me quite baffled.
Here's a long shot:
class unicode(object):
pass
test = unicode()
test.replace()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'unicode' object has no attribute 'replace'
Are there fake unicode objects somewhere? (Like I said, a long shot.) If you find the line of code where it's happening, put a try/except around it, print/log a repr of the object causing the problem, then reraise the error.
I am getting an error (see below) when trying to use cv.CreateHist in Python. I
am also noticing another alarming problem. If I spit out all of the attributes
of the cv module into a file, and then I search them, I find that a ton of
common things are missing.
For example, cv.TermCriteria() is not there; cv.ConnectedComp is not there; and
cv.CvRect is not there.
Everything about my installation, with Open CV 2.2, worked just fine. I can plot
images, make CvScalars, and call plenty of the functions, like cv.CamShift...
but there are a dozen or so of these hit-or-miss functions or data structures
that are simply missing with no explanation.
Here's my code for cv.CreateHist:
import cv
q = cv.CreateHist([1],1,cv.CV_HIST_ARRAY)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: x9y��
The weird wingding stuff is actually what it spits out at the command line, not a copy-paste error. Can anyone help figure this out? It's incredibly puzzling.
Ely
As for CvRect, see the documentation. It says such types are represented as Pythonic tuples.
As for your call to CreateHist, you may be passing the arguments in wrong order. See createhist in the docs for python opencv.