python-3.6

Python TypeError: must be str, not int

点点圈 提交于 2019-12-11 07:05:54
问题 I'm using Python 3.6.2 on Windows 64-bit, I have an error: A TypeError.... A = 0 ns = input('Input start:') nf = input('Input finish:') steps = input('Input steps:') for i in range(steps + 1): d_n = (nf-ns)/steps n = ns + i * d_n f_n = n*n A = A + f_n * d_n next print('Area is: ', A) And here's the error.... Traceback (most recent call last): File "C:/Users/UNO/Documents/Python 3.6/Curve_Area2.py", line 5, in <module> for i in range(steps + 1): TypeError: must be str, not int And I want this

RuntimeError 'DivBackward0' nan values in its 0th output, but works when tensors loaded from disk?

雨燕双飞 提交于 2019-12-11 06:31:53
问题 I'm trying to implement a particular loss function in PyTorch called SMAPE (commonly used in time series forecasting). I have two variables, model_outputs and target_outputs , and the formula for computing the element-wise SMAPE is straight-forward: numerator = torch.abs(model_outputs - target_outputs) denominator = torch.abs(model_outputs) + torch.abs(target_outputs) elementwise_smape = torch.div(numerator, denominator) nan_mask = torch.isnan(elementwise_smape) loss = elementwise_smape[~nan

Is there a way using Python 3 IMAPlib to retrieve both the sender address & the associated UID for a given message

女生的网名这么多〃 提交于 2019-12-11 06:20:21
问题 Using regular expressions I have managed to extract all sender addresses from the emails located in my Inbox, However I've tried and failed many times to also extract the associated UIDs for those individual emails. Here's what I have so far: result, data = mail.search(None, 'ALL') ids = data[0] id_list = ids.split() for i in id_list: typ, data = mail.fetch(i,'(RFC822)') for response_part in data: if isinstance(response_part, tuple): msg = email.message_from_bytes(response_part[1]) sender =

Python 3.6: trying to pip install numpy

本秂侑毒 提交于 2019-12-11 06:13:17
问题 I'm just trying a simple pip3.6 install numpy , and I get the following error: distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('numpy>=1.7.0') How can this be solved? I tried to upgrade easy_install but that did not work, neither did trying to install scikit-learn directly. Note that I already have been using python3.5. 回答1: Actually, a bit above the error I ended up noticing: Download error on https://pypi.python.org/simple/numpy/: [SSL:

Pandas dataframe transpose with column name instead of index throws ValueError

↘锁芯ラ 提交于 2019-12-11 05:58:03
问题 I am trying to show actual column name in json after dataframe has been transposed, below code works for LIMIT 3 in sql but fails if I try LIMIT 5 Any thoughts please? from pandasql import * pysqldf = lambda q: sqldf(q, globals()) q1 = """ SELECT beef as beef, veal as veal, pork as pork, lamb_and_mutton as lamb FROM meat m LIMIT 5; """ meat = load_meat() df = pysqldf(q1) #print(df.to_json(orient='records')) hdf = pd.DataFrame(df) print(hdf.T.reset_index().set_axis(range(len(hdf.columns)),

Python 3 pip installation of pygraphviz fails, “Microsoft Visual C++ is required”, Visual Studio 2017 is installed

你说的曾经没有我的故事 提交于 2019-12-11 05:45:31
问题 I tried to pip install pygraphviz , which failed with the error: "Microsoft Visual C++ 14.0 is required. ..." I have Visual Studio 2017 installed. Shouldn't that do the job? I think I checked every box related to C. If I try to install vc_redist.x64.exe, it tells me another version is already installed. (I think I have a similar/related problem with SciKit-learn and Scipy.) 回答1: From PyGraphviz documentation - To use PyGraphviz you need Python version 2.6.x or 2.7.x. PyGraphviz does not work

Wait for stdout on Popen

假如想象 提交于 2019-12-11 05:27:02
问题 I am trying to setting up an acceptance test harness for a flask app and I am currently struggling to wait for the app to start before making calls. Following construct works fine: class SpinUpTests(unittest.TestCase): def tearDown(self): super().tearDown() self.stubby_server.kill() self.stubby_server.communicate() def test_given_not_yet_running_when_created_without_config_then_started_on_default_port(self): self.not_yet_running(5000) self.stubby_server = subprocess.Popen(['python', '../..

pip for python3.6.5 on debian9.4

帅比萌擦擦* 提交于 2019-12-11 05:07:44
问题 I recently Installed python3.6 on debian 9.4 by these commands wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz tar xvf Python-3.6.5.tgz cd Python-3.6.5 ./configure --enable-optimizations --with-ensurepip=install make -j8 sudo make altinstall python3.6 it worked when i type python3.6 but pip doesn't installed on python3.6 so i decided to install it manually by these commands curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py sudo python3.6 get-pip.py i get this error

Lists to numpy array

谁都会走 提交于 2019-12-11 04:55:14
问题 Why does the following code generate a numpy array with lists printed inside the array for list3? enter image description here Output observed: list2=[[1,2,3],[4,5,6],[7,8,9]] #list of 3 lists makes 3 rows and 3 columns for numpy array #each list fills one row print('List2',list2) print('List2 casted as 3x3 array',np.array(list2)) list3=[[1,2,3],[4,5,6],[7,8]] print(np.array(list3)) 来源: https://stackoverflow.com/questions/56455371/lists-to-numpy-array

Sqlite3 cursors live updating?

风流意气都作罢 提交于 2019-12-11 04:46:01
问题 Can someone please explain this to me: import sqlite3 db = sqlite3.connect(':memory:') db.execute('create table t1 (id integer primary key, val text)') db.execute('create table t2 (id integer primary key, val text)') c = db.cursor() c.execute('insert into t1 values (?, ?)', (1, 'a')) c.execute('insert into t2 values (?, ?)', (1, 'b')) c.execute('insert into t1 values (?, ?)', (2, 'c')) c.execute('insert into t2 values (?, ?)', (2, 'd')) c.execute('''select t1.id, t1.val, t2.val from t1 left