attributeerror

import urllib.parse fails when Python run from command line

本秂侑毒 提交于 2019-12-01 18:27:08
问题 I have observed the following behavior in python 3.4.2, and I am unableto explain it. Hopefully someone could shed some light on the matter: In IPython: In [129]: import urllib In [130]: print(urllib.parse) <module 'urllib.parse' from '/Users/ashwin/.pyenv/versions/3.4.2/lib/python3.4/urllib/parse.py'> I've imported a module, and printed one of its attributes. Everything works as expected. So far, life is good. Now, I do the same thing from the command line: $ python -c 'import urllib; print

Why do I get an AttributeError when using pandas apply?

十年热恋 提交于 2019-12-01 16:30:14
问题 How should I convert NaN value into categorical value based on condition. I am getting error while trying to convert Nan value. category gender sub-category title health&beauty NaN makeup lipbalm health&beauty women makeup lipstick NaN NaN NaN lipgloss My DataFrame looks like this. And my function to convert NaN values in gender to categorical value looks like def impute_gender(cols): category=cols[0] sub_category=cols[2] gender=cols[1] title=cols[3] if title.str.contains('Lip') and gender

AttributeError: 'Tensor' object has no attribute 'numpy'

左心房为你撑大大i 提交于 2019-12-01 16:16:13
How can I fix this error I downloaded this code from GitHub. predicted_id = tf.multinomial(tf.exp(predictions), num_samples=1)[0][0].numpy() throws the error AttributeError: 'Tensor' object has no attribute 'numpy' Please help me fix this! I used: sess = tf.Session() with sess.as_default(): predicted_id = tf.multinomial(tf.exp(predictions), num_samples=1)[0][0].eval() And i get this error. Someone help me i just want it to work why is this so hard? D:\Python>python TextGenOut.py File "TextGenOut.py", line 72 predicted_id = tf.multinomial(tf.exp(predictions), num_samples=1)[0][0].eval() ^

networkx DiGraph Attribute Error self._succ

给你一囗甜甜゛ 提交于 2019-12-01 11:32:48
Context : I'm trying to run another researcher's code - it describes a traffic model for the Bay Area road network, which is subject to seismic hazard. I'm new to Python and therefore would really appreciate some help debugging the following error. Issue : When I try to run the code for the sample data provided with the file, following the instructions in the README, I get the following error. DN0a226926:quick_traffic_model gitanjali$ python mahmodel_road_only.py You are considering 2 ground-motion intensity maps. You are considering 1743 different site locations. You are considering 2

networkx DiGraph Attribute Error self._succ

耗尽温柔 提交于 2019-12-01 07:28:06
问题 Context : I'm trying to run another researcher's code - it describes a traffic model for the Bay Area road network, which is subject to seismic hazard. I'm new to Python and therefore would really appreciate some help debugging the following error. Issue : When I try to run the code for the sample data provided with the file, following the instructions in the README, I get the following error. DN0a226926:quick_traffic_model gitanjali$ python mahmodel_road_only.py You are considering 2 ground

Python: accessing DLL function using ctypes — access by function *name* fails

◇◆丶佛笑我妖孽 提交于 2019-12-01 04:06:41
myPythonClient (below) wants to invoke a ringBell function (loaded from a DLL using ctypes ). However, attempting to access ringBell via its name results in an AttributeError . Why? RingBell.h contains namespace MyNamespace { class MyClass { public: static __declspec(dllexport) int ringBell ( void ) ; } ; } RingBell.cpp contains #include <iostream> #include "RingBell.h" namespace MyNamespace { int __cdecl MyClass::ringBell ( void ) { std::cout << "\a" ; return 0 ; } } myPythonClient.py contains from ctypes import * cdll.RingBell[1]() # this invocation works fine cdll.RingBell.ringBell() #

How to fix AttributeError: module 'numpy' has no attribute 'square' [closed]

本秂侑毒 提交于 2019-12-01 04:05:23
I have updated numpy to 1.14.0. I use Windows 10. I tried to run my code and I got this error: AttributeError: module 'numpy' has no attribute 'square' Here are my imports: %matplotlib inline import matplotlib.pyplot as plt import tensorflow as tf import numpy as np from sklearn.metrics import confusion_matrix import math I removed numpy.py then updated my numpy and it worked! 来源: https://stackoverflow.com/questions/48235169/how-to-fix-attributeerror-module-numpy-has-no-attribute-square

How to fix AttributeError: module 'numpy' has no attribute 'square' [closed]

风格不统一 提交于 2019-12-01 01:55:00
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I have updated numpy to 1.14.0. I use Windows 10. I tried to run my code and I got this error: AttributeError: module 'numpy' has no attribute 'square' Here are my imports: %matplotlib inline import matplotlib.pyplot as plt import tensorflow as tf import numpy as np from sklearn.metrics import confusion_matrix

Formatting dict keys: AttributeError: 'dict' object has no attribute 'keys()'

只谈情不闲聊 提交于 2019-11-30 15:11:42
What is the proper way to format dict keys in string? When I do this: >>> foo = {'one key': 'one value', 'second key': 'second value'} >>> "In the middle of a string: {foo.keys()}".format(**locals()) What I expect: "In the middle of a string: ['one key', 'second key']" What I get: Traceback (most recent call last): File "<pyshell#4>", line 1, in <module> "In the middle of a string: {foo.keys()}".format(**locals()) AttributeError: 'dict' object has no attribute 'keys()' But as you can see, my dict has keys: >>> foo.keys() ['second key', 'one key'] You can't call methods in the placeholders. You

AttributeError(“'str' object has no attribute 'read'”)

六眼飞鱼酱① 提交于 2019-11-30 10:18:00
问题 In Python I'm getting an error: Exception: (<type 'exceptions.AttributeError'>, AttributeError("'str' object has no attribute 'read'",), <traceback object at 0x1543ab8>) Given python code: def getEntries (self, sub): url = 'http://www.reddit.com/' if (sub != ''): url += 'r/' + sub request = urllib2.Request (url + '.json', None, {'User-Agent' : 'Reddit desktop client by /user/RobinJ1995/'}) response = urllib2.urlopen (request) jsonofabitch = response.read () return json.load (jsonofabitch)[