python-3.x

Different behaviour of ctypes c_char_p?

倖福魔咒の 提交于 2021-02-18 09:51:13
问题 I am confused with this behaviour of different versions of python and dont understand why ? Python 2.7.5 (default, Aug 25 2013, 00:04:04) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> c="hello" >>> a=ctypes.c_char_p(c) >>> print(a.value) hello Python 3.3.5 (default, Mar 11 2014, 15:08:59) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin Type "help", "copyright", "credits" or "license"

Python 3.4 multiprocessing Queue faster than Pipe, unexpected

冷暖自知 提交于 2021-02-18 08:56:50
问题 I am doing an audio player that received samples from an udp socket, and everything was working fine. But when I implemented an Lost Concealment algorithm, the player failed to keep producing silence at the excepted rate (each 10ms send a list of multiple 160 bytes). When playing audio with pyaudio, using the blocking call write to play some samples, I noticed it blocked on average for duration of the sample. So I created a new dedicated process to play the samples. The main process processes

Eval scope in Python 2 vs. 3

让人想犯罪 __ 提交于 2021-02-18 08:52:07
问题 I came across bizarre eval behavior in Python 3 - local variables aren't picked up when eval is called in a list comprehension. def apply_op(): x, y, z = [0.5, 0.25, 0.75] op = "x,y,z" return [eval(o) for o in op.split(",")] print(apply_op()) It errors in Python 3: ▶ python --version Python 3.4.3 ▶ python eval.py Traceback (most recent call last): File "eval.py", line 7, in <module> print(apply_op()) File "eval.py", line 5, in apply_op return [eval(o) % 1 for o in op.split(",")] File "eval.py

Why pyautogui click not actually clicking

拈花ヽ惹草 提交于 2021-02-18 08:43:19
问题 I try to use the click function of Pyautogui, but the actual click doesn't happen or at least there is no change at the page though it moves the mouse to the right place. The window is in focus (I think) because the program works well with other pages. I could only find one relevant question: having trouble clicking in program - pyautogui. However, there was no accepted answer for that and I tried the given answer in the link but didn't work (It was in python2 but I'm in python3). I use Linux

How to do Cohen Kappa Quadratic Loss in Tensorflow 2.0?

痴心易碎 提交于 2021-02-18 08:16:14
问题 I'm trying to create the loss function according to: How can I specify a loss function to be quadratic weighted kappa in Keras? But in tensorflow 2.0: tf.contrib.metrics.cohen_kappa No longer exists. Is there an alternative? 回答1: def kappa_loss(y_pred, y_true, y_pow=2, eps=1e-10, N=4, bsize=256, name='kappa'): """A continuous differentiable approximation of discrete kappa loss. Args: y_pred: 2D tensor or array, [batch_size, num_classes] y_true: 2D tensor or array,[batch_size, num_classes] y

Exception in thread “main” java.lang.UnsatisfiedLinkError: no jep in java.library.path

若如初见. 提交于 2021-02-18 08:13:11
问题 I have 'libjep.so' file after downloading jep and I also had set the environmental variable LD_LIBRARY_PATH in ~./bashrc as shown below: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python2.7/dist-packages/jep/libjep.so as well as in runtime System.load("/usr/local/lib/python2.7/dist-packages/jep/libjep.so"); But when I have the follwing line in my code, Jep jep = new Jep(); It shows the below error: Exception in thread "main" java.lang.UnsatisfiedLinkError: no jep in java.library

Python Histogram ValueError: range parameter must be finite

扶醉桌前 提交于 2021-02-18 08:05:16
问题 when plotting Pandas dataframe using a histogram, sample dataframe data distance 0 5.680195 2 0.000000 3 7.974658 4 2.461387 5 9.703089 code I use to plot import matplotlib.pyplot as plt plt.hist(df['distance'].values) plt.show() I have this error "ValueError: range parameter must be finite." my attempt df['Round_Distance'] = df['distance'].round(1) 0 5.7 2 0.0 3 8.0 4 2.5 5 9.7 plot again, new error plt.hist(df['Round_Distance'].values) plt.show() ValueError: max must be larger than min in

Python Histogram ValueError: range parameter must be finite

[亡魂溺海] 提交于 2021-02-18 08:04:32
问题 when plotting Pandas dataframe using a histogram, sample dataframe data distance 0 5.680195 2 0.000000 3 7.974658 4 2.461387 5 9.703089 code I use to plot import matplotlib.pyplot as plt plt.hist(df['distance'].values) plt.show() I have this error "ValueError: range parameter must be finite." my attempt df['Round_Distance'] = df['distance'].round(1) 0 5.7 2 0.0 3 8.0 4 2.5 5 9.7 plot again, new error plt.hist(df['Round_Distance'].values) plt.show() ValueError: max must be larger than min in

Error in installing JPype1 in Python 3.7 on Mac OS 10.14.2

此生再无相见时 提交于 2021-02-18 07:55:47
问题 I am getting error while installing JPype1 in my system. I am using Python 3.7. JPype1 is required as dependency for Jaydebeapi. pip install Jpype1 Following are the error message: Collecting jpype1 Using cached https://files.pythonhosted.org/packages/c4/4b/60a3e63d51714d4d7ef1b1efdf84315d118a0a80a5b085bb52a7e2428cdc/JPype1-0.6.3.tar.gz Building wheels for collected packages: jpype1 Running setup.py bdist_wheel for jpype1 ... error Complete output from command /Users/citius/anaconda3/bin

Installation fails for Fiona and Geopandas with GDAL on Python 3.6 on Microsoft Windows OS?

做~自己de王妃 提交于 2021-02-18 07:54:30
问题 I need to install Geopandas which depends on Fiona and GDAL with pip on Python 3.6. I have installed the GDAL library on Python using the wheel file downloaded from here. Processing c:\users\_chena\downloads\gdal-2.4.1-cp36-cp36m-win_amd64.whl Installing collected packages: GDAL Successfully installed GDAL-2.4.1 Then I tried to pip3 install geopandas . I encountered the following error: Collecting geopandas Downloading https://files.pythonhosted.org/packages/f0/5d/916b7268ef551fa9647c