python-3.5

Error: Failed building wheel for wxpython-phoenix while installing wx

北慕城南 提交于 2019-12-23 17:26:23
问题 I am trying to install wxpython (I have python 3.5.2(32Bit) and Windows 10(64Bit)) I tried : pip install wx and i get: Failed building wheel for wxpython-phoenix 2 times and then a big error line--> I also tried installing Anaconda, but it did not help.How can I overcome the problem ? 回答1: There's a lot of questions about failed installations on windows, probably because the packages are compiled when installed, and sometimes the compilation fail when the compiler is not properly configured.

while_loop error in Tensorflow

扶醉桌前 提交于 2019-12-23 16:14:41
问题 I tried to use while_loop in Tensorflow , but when I try to return the target output from callable in while loop, it gives me an error because the shape is increased every time. The output should be contains (0 or 1) values based on data value (input array). If data value is large than 5 return 1 else return 0 . The returned value must be added into output This is the code:: import numpy as np import tensorflow as tf data = np.random.randint(10, size=(30)) data = tf.constant(data, dtype= tf

How to perfectly convert one-element list to tuple in Python?

本小妞迷上赌 提交于 2019-12-23 12:16:54
问题 So I am trying to do this: tuple([1]) The output I expect is : (1) However, I got this: (1,) But if I do this: tuple([1,2]) It works perfectly! like this: (1,2) This is so weird that I don't know why the tuple function cause this result. Please help me to fix it. 回答1: This is such a common question that the Python Wiki has a page dedicated to it: One Element Tuples One-element tuples look like: 1, The essential element here is the trailing comma. As for any expression, parentheses are

The `out` arguments in `numpy.einsum` can not work as expected

∥☆過路亽.° 提交于 2019-12-23 10:52:56
问题 I have two piece codes. The first one is: A = np.arange(3*4*3).reshape(3, 4, 3) P = np.arange(1, 4) A[:, 1:, :] = np.einsum('j, ijk->ijk', P, A[:, 1:, :]) and the result A is : array([[[ 0, 1, 2], [ 6, 8, 10], [ 18, 21, 24], [ 36, 40, 44]], [[ 12, 13, 14], [ 30, 32, 34], [ 54, 57, 60], [ 84, 88, 92]], [[ 24, 25, 26], [ 54, 56, 58], [ 90, 93, 96], [132, 136, 140]]]) The second one is: A = np.arange(3*4*3).reshape(3, 4, 3) P = np.arange(1, 4) np.einsum('j, ijk->ijk', P, A[:, 1:, :], out=A[:,1:,

Python 3: Sphinx doesn't show type hints correctly

为君一笑 提交于 2019-12-23 08:39:40
问题 I am generating a HTML documentation of a Python 3 module automatically from its reStructuredText docstrings of its functions by using Sphinx (make HTML). The generated HTML documentation looks fine so far, but the parameter types of the function signatures, which are given in the source code as PEP484 type hints aren't shown correctly. E.g. this is some example output from the Sphinx-generated HTML doc of one of my functions: static parse_from_file(filename: str) → list Parses stuff from a

correctly override __new__ in python3

喜欢而已 提交于 2019-12-23 03:01:46
问题 So I am trying override __new__ and let it exist as a factory to create derived instances. After reading a bit on SO, I am under the impression that I should be calling __new__ on the derived instance as well. BaseThing class BaseThing: def __init(self, name, **kwargs): self.name = name # methods to be derived ThingFactory class Thing(BaseThing): def __new__(cls, name, **kwargs): if name == 'A': return A.__new__(name, **kwargs) if name == 'B': return B.__new__(name, **kwargs) def __init__

Python word count program from txt file

人走茶凉 提交于 2019-12-22 17:53:48
问题 I'm trying to write a program that counts the 5 most common words in a txt file. Here is what I have so far: file = open('alice.txt') wordcount = {} for word in file.read().split(): if word not in wordcount: wordcount[word] = 1 else: wordcount[word] += 1 for k, v in wordcount.items(): print (k, v) The program as it is counts every word in the .txt file. My question is how to make it so it only counts the 5 most common words in the file so that it displays the words and the word count next to

Scraping: add data stored as a picture to CSV file in python 3.5

让人想犯罪 __ 提交于 2019-12-22 17:46:52
问题 For this project, I am scraping data from a database and attempting to export this data to a spreadsheet for further analysis. (Previously posted here--thanks for the help over there reworking my code!) I previously thought that finding the winning candidate in the table could be simplified by just always selecting the first name that appears in the table, as I thought the "winners" always appeared first. However, this is not the case. Whether or not a candidate was elected is stored in the

LINK : fatal error LNK1104: cannot open file 'MSVCRT.lib'

跟風遠走 提交于 2019-12-22 15:37:31
问题 I am trying to download a channels package for making a chatbot by using google tensorflow. But, I am getting the following error: 3.5\twisted\words\im copying src\twisted\words\xish\xpathparser.g -> build\lib.win-amd64-3.5\twis ted\words\xish running build_ext building 'twisted.test.raiser' extension creating build\temp.win-amd64-3.5 creating build\temp.win-amd64-3.5\Release creating build\temp.win-amd64-3.5\Release\src creating build\temp.win-amd64-3.5\Release\src\twisted creating build

pythonnet Embedding Python in .net example failing to load module

跟風遠走 提交于 2019-12-22 11:31:17
问题 I'm trying to run the Embedding Python in .NET example from https://github.com/pythonnet/pythonnet. I've followed troubleshooting articles to set the proper %PYTHONPATH% and %PYTHONHOME% to my anaconda environment in the program base directory. After activating my anaconda environment, I have successfully imported sys, and imp as a test, and also sucessfully used PythonEngine.RunSimpleString(), but the numpy example fails with Python.Runtime.PythonException: ImportError : No module named