qid int64 46k 74.7M | question stringlengths 54 37.8k | date stringlengths 10 10 | metadata listlengths 3 3 | response_j stringlengths 17 26k | response_k stringlengths 26 26k |
|---|---|---|---|---|---|
47,689,456 | I was trying to connect oracle database using python like below.
```
import cx_Oracle
conn = cx_Oracle.connect('user/password@host:port/database')
```
I've faced an error when connecting oracle.
DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "libclntsh.so: cannot open shared object file: No ... | 2017/12/07 | [
"https://Stackoverflow.com/questions/47689456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3176741/"
] | That error indicates that you are missing a 64-bit Oracle client installation or it hasn't been configured correctly. Take a look at the link mentioned in the error message. It will give instructions on how to perform the Oracle client installation and configuration.
[Update on behalf of Anthony: his latest cx\_Oracle... | This error come when your Oracle Client is not installed or LD\_LIBRARY\_PATH is not set where libclntsh.so is present.
if you have Oracle client installed then search for libclntsh.so and set the LD\_LIBRARY\_PATH as
"export LD\_LIBRARY\_PATH=/app/bds/parcels/ORACLE\_INSTANT\_CLIENT/instantclient\_11\_2:$LD\_LIBRAR... |
47,689,456 | I was trying to connect oracle database using python like below.
```
import cx_Oracle
conn = cx_Oracle.connect('user/password@host:port/database')
```
I've faced an error when connecting oracle.
DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "libclntsh.so: cannot open shared object file: No ... | 2017/12/07 | [
"https://Stackoverflow.com/questions/47689456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3176741/"
] | That error indicates that you are missing a 64-bit Oracle client installation or it hasn't been configured correctly. Take a look at the link mentioned in the error message. It will give instructions on how to perform the Oracle client installation and configuration.
[Update on behalf of Anthony: his latest cx\_Oracle... | Here is the full program to connect Oracle using python.
First, you need to install cx\_Oracle. to install it fire the below command.
`pip install cx_Oracle`
```js
import cx_Oracle
def get_databse_coonection():
try:
host='hostName'
port ='portnumber'
serviceName='sid of you database'... |
47,689,456 | I was trying to connect oracle database using python like below.
```
import cx_Oracle
conn = cx_Oracle.connect('user/password@host:port/database')
```
I've faced an error when connecting oracle.
DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "libclntsh.so: cannot open shared object file: No ... | 2017/12/07 | [
"https://Stackoverflow.com/questions/47689456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3176741/"
] | This error come when your Oracle Client is not installed or LD\_LIBRARY\_PATH is not set where libclntsh.so is present.
if you have Oracle client installed then search for libclntsh.so and set the LD\_LIBRARY\_PATH as
"export LD\_LIBRARY\_PATH=/app/bds/parcels/ORACLE\_INSTANT\_CLIENT/instantclient\_11\_2:$LD\_LIBRAR... | Here is the full program to connect Oracle using python.
First, you need to install cx\_Oracle. to install it fire the below command.
`pip install cx_Oracle`
```js
import cx_Oracle
def get_databse_coonection():
try:
host='hostName'
port ='portnumber'
serviceName='sid of you database'... |
53,649,039 | I have a Databricks notebook setup that works as the following;
* pyspark connection details to Blob storage account
* Read file through spark dataframe
* convert to pandas Df
* data modelling on pandas Df
* convert to spark Df
* write to blob storage in single file
My problem is, that you can not name the file outpu... | 2018/12/06 | [
"https://Stackoverflow.com/questions/53649039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6050134/"
] | >
> I know the compiler is supposed to generate an error for templates that are erroneous for any template parameter even if not instantiated.
>
>
>
That is not the case, though. If no instantiation can be generated for a template, then the program is ill-formed, **no diagnostic required**(1). So the program is il... | While it's largely a quality of implementation issue, `-Werror` can indeed (and does) interfere with SFINAE. Here is a more involved example to test it:
```
#include <type_traits>
template <typename T>
constexpr bool foo() {
if (false) {
T a;
}
return false;
}
template<typename T, typename = void... |
40,476,046 | i'm actually an amateur python programmer and am trying to use the django framework for an android app backend. everything is okay but my problem is actually how to pass the image in the Filefield to JSON. i have tried using SerializerMethodField as described in the rest framework documentation but didn't work. sorry i... | 2016/11/07 | [
"https://Stackoverflow.com/questions/40476046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6214350/"
] | If you want to check if two files are equal, you can check the exit code of `diff -q` (or `cmp`). This is faster since it doesn't require finding the exact differences:
```
if diff -q file1 file2 > /dev/null
then
echo "The files are equal"
else
echo "The files are different or inaccessible"
fi
```
All Unix tools... | You can use the logic pipe:
For one command:
```
diff -q file1 file2 > /dev/null && echo "The files are equal"
```
Or more commands:
```
diff -q file1 file2 > /dev/null && {
echo "The files are equal"; echo "Other command"
echo "More other command"
}
``` |
56,181,987 | I installed PySpark on Amazon AWS using instructions:
<https://medium.com/@josemarcialportilla/getting-spark-python-and-jupyter-notebook-running-on-amazon-ec2-dec599e1c297>
This works fine:
```py
Import pyspark as SparkContext
```
This gives error:
```
sc = SparkContext()
TypeError ... | 2019/05/17 | [
"https://Stackoverflow.com/questions/56181987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11270319/"
] | You can just use the copy constructor of `ArrayList` which accepts a `Collection<? extends E>`:
```
List<GtbEtobsOYenibelge> listOnayStatu = servis.listOnayStatus4Belge(user.getBirimId().getId());
List<GtbEtobsOYenibelge> cloneOnayStatu = new ArrayList<>(listOnayStatu);
```
That way you create a copy of `listOnaySta... | The method `servis.listOnayStatus4Belge` returns a [Vector](https://docs.oracle.com/javase/8/docs/api/index.html). A `Vector` implements the `List` interface but is not an `ArrayList`. Therefore you can't cast it to one.
Looking at the problematic statement:
```
cloneOnayStatu = ((List) ((ArrayList) listOnayStatu).c... |
56,181,987 | I installed PySpark on Amazon AWS using instructions:
<https://medium.com/@josemarcialportilla/getting-spark-python-and-jupyter-notebook-running-on-amazon-ec2-dec599e1c297>
This works fine:
```py
Import pyspark as SparkContext
```
This gives error:
```
sc = SparkContext()
TypeError ... | 2019/05/17 | [
"https://Stackoverflow.com/questions/56181987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11270319/"
] | You can just use the copy constructor of `ArrayList` which accepts a `Collection<? extends E>`:
```
List<GtbEtobsOYenibelge> listOnayStatu = servis.listOnayStatus4Belge(user.getBirimId().getId());
List<GtbEtobsOYenibelge> cloneOnayStatu = new ArrayList<>(listOnayStatu);
```
That way you create a copy of `listOnaySta... | You can try to save it as a new arraylist.
```
List<GtbEtobsOYenibelge> listOnayStatu = new ArrayList<>();
List<GtbEtobsOYenibelge> cloneOnayStatu;
listOnayStatu = servis.listOnayStatus4Belge(user.getBirimId().getId());
cloneOnayStatu = new ArrayList(listOnayStatu);
```
or you can use addAll
```
cloneOnayStatu.add... |
41,492,878 | I tried to install "scholarly" package, but I keep receiving this error:
```
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c build/temp.li... | 2017/01/05 | [
"https://Stackoverflow.com/questions/41492878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5413088/"
] | I had the same problem.
This one helped me:
```
sudo apt-get install build-essential libssl-dev libffi-dev python-dev
```
If you are using `python3`, try to replace `python-dev` with `python3-dev` | Install lib32ncurses5-dev:
```
sudo apt-get install lib32ncurses5-dev
``` |
41,492,878 | I tried to install "scholarly" package, but I keep receiving this error:
```
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c build/temp.li... | 2017/01/05 | [
"https://Stackoverflow.com/questions/41492878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5413088/"
] | I had the same problem.
This one helped me:
```
sudo apt-get install build-essential libssl-dev libffi-dev python-dev
```
If you are using `python3`, try to replace `python-dev` with `python3-dev` | In my case the exception was:
**Exception:**
```
#include <snappy-c.h>
^~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit
status 1
```
And I solved it by installing these libraries:
```
sudo apt-get install libsnappy-dev
pip3 install python-snappy
```
[Here](ht... |
41,492,878 | I tried to install "scholarly" package, but I keep receiving this error:
```
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c build/temp.li... | 2017/01/05 | [
"https://Stackoverflow.com/questions/41492878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5413088/"
] | I had the same problem.
This one helped me:
```
sudo apt-get install build-essential libssl-dev libffi-dev python-dev
```
If you are using `python3`, try to replace `python-dev` with `python3-dev` | In a newly created `python 3.6`, virtual environment and trying to run my `setup.py` of my module, the following command solved the error,
`sudo apt-get install python3.6-dev`
For me the error was,
```
... Python.h: No such file or directory
18 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
er... |
41,492,878 | I tried to install "scholarly" package, but I keep receiving this error:
```
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c build/temp.li... | 2017/01/05 | [
"https://Stackoverflow.com/questions/41492878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5413088/"
] | Install lib32ncurses5-dev:
```
sudo apt-get install lib32ncurses5-dev
``` | In my case the exception was:
**Exception:**
```
#include <snappy-c.h>
^~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit
status 1
```
And I solved it by installing these libraries:
```
sudo apt-get install libsnappy-dev
pip3 install python-snappy
```
[Here](ht... |
41,492,878 | I tried to install "scholarly" package, but I keep receiving this error:
```
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c build/temp.li... | 2017/01/05 | [
"https://Stackoverflow.com/questions/41492878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5413088/"
] | Install lib32ncurses5-dev:
```
sudo apt-get install lib32ncurses5-dev
``` | In a newly created `python 3.6`, virtual environment and trying to run my `setup.py` of my module, the following command solved the error,
`sudo apt-get install python3.6-dev`
For me the error was,
```
... Python.h: No such file or directory
18 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
er... |
41,492,878 | I tried to install "scholarly" package, but I keep receiving this error:
```
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c build/temp.li... | 2017/01/05 | [
"https://Stackoverflow.com/questions/41492878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5413088/"
] | In a newly created `python 3.6`, virtual environment and trying to run my `setup.py` of my module, the following command solved the error,
`sudo apt-get install python3.6-dev`
For me the error was,
```
... Python.h: No such file or directory
18 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
er... | In my case the exception was:
**Exception:**
```
#include <snappy-c.h>
^~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit
status 1
```
And I solved it by installing these libraries:
```
sudo apt-get install libsnappy-dev
pip3 install python-snappy
```
[Here](ht... |
39,983,159 | This is the code that results in an error message:
```
import urllib
import xml.etree.ElementTree as ET
url = raw_input('Enter URL:')
urlhandle = urllib.urlopen(url)
data = urlhandle.read()
tree = ET.parse(data)
```
The error:

I'm new to python. I di... | 2016/10/11 | [
"https://Stackoverflow.com/questions/39983159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6938631/"
] | `data` is a reference to the XML content as a string, but the [`parse()`](https://docs.python.org/2.7/library/xml.etree.elementtree.html#xml.etree.ElementTree.parse) function expects a filename or [file object](https://docs.python.org/2/glossary.html#term-file-object) as argument. That's why there is an an error.
`url... | The error message indicates that your code is trying to open a file, who's name is stored in the variable source.
It's failing to open that file (IOError) because the variable source contains a bunch of XML, not a file name. |
39,983,159 | This is the code that results in an error message:
```
import urllib
import xml.etree.ElementTree as ET
url = raw_input('Enter URL:')
urlhandle = urllib.urlopen(url)
data = urlhandle.read()
tree = ET.parse(data)
```
The error:

I'm new to python. I di... | 2016/10/11 | [
"https://Stackoverflow.com/questions/39983159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6938631/"
] | Consider using ElementTree's [`fromstring()`](https://docs.python.org/2/library/xml.etree.elementtree.html#xml.etree.ElementTree.fromstring):
```
import urllib
import xml.etree.ElementTree as ET
url = raw_input('Enter URL:')
# http://feeds.bbci.co.uk/news/rss.xml?edition=int
urlhandle = urllib.urlopen(url)
data ... | The error message indicates that your code is trying to open a file, who's name is stored in the variable source.
It's failing to open that file (IOError) because the variable source contains a bunch of XML, not a file name. |
39,983,159 | This is the code that results in an error message:
```
import urllib
import xml.etree.ElementTree as ET
url = raw_input('Enter URL:')
urlhandle = urllib.urlopen(url)
data = urlhandle.read()
tree = ET.parse(data)
```
The error:

I'm new to python. I di... | 2016/10/11 | [
"https://Stackoverflow.com/questions/39983159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6938631/"
] | Consider using ElementTree's [`fromstring()`](https://docs.python.org/2/library/xml.etree.elementtree.html#xml.etree.ElementTree.fromstring):
```
import urllib
import xml.etree.ElementTree as ET
url = raw_input('Enter URL:')
# http://feeds.bbci.co.uk/news/rss.xml?edition=int
urlhandle = urllib.urlopen(url)
data ... | `data` is a reference to the XML content as a string, but the [`parse()`](https://docs.python.org/2.7/library/xml.etree.elementtree.html#xml.etree.ElementTree.parse) function expects a filename or [file object](https://docs.python.org/2/glossary.html#term-file-object) as argument. That's why there is an an error.
`url... |
55,436,590 | I am a beginner trying to learn Python. I wrote a program using Geany and would like to build and execute it but I keep getting this error: "The system cannot find the path specified". I believe I added the right info to the Path though:
```
Compile C:\Python373\python -m py_compile "%f"
Execute C:\Python373\python "... | 2019/03/30 | [
"https://Stackoverflow.com/questions/55436590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10286420/"
] | You can try this solution
First open `sdkmanager.bat` with any text editor
Then find this line
```
%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SDKMANAGER_OPTS%
```
And change it to this line
```
%JAVA_EXE%" %DEFAULT_JVM_OPTS% --add-modules java.xml.bind %JAVA_OPTS% %SDKMANAGER_OPTS%
```
I hope this solve... | I had to do the following to fix this error on Windows 10:
1. Install JDK 8. I had JDK 12 installed but it did not seem to work with that version.
2. Add Java to my environment variable Path
To add Java to your environment variable Path do the following:
`Go to Computer -> Advanced system settings -> Environment var... |
55,436,590 | I am a beginner trying to learn Python. I wrote a program using Geany and would like to build and execute it but I keep getting this error: "The system cannot find the path specified". I believe I added the right info to the Path though:
```
Compile C:\Python373\python -m py_compile "%f"
Execute C:\Python373\python "... | 2019/03/30 | [
"https://Stackoverflow.com/questions/55436590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10286420/"
] | You can try this solution
First open `sdkmanager.bat` with any text editor
Then find this line
```
%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SDKMANAGER_OPTS%
```
And change it to this line
```
%JAVA_EXE%" %DEFAULT_JVM_OPTS% --add-modules java.xml.bind %JAVA_OPTS% %SDKMANAGER_OPTS%
```
I hope this solve... | I had the issue as default installation of java was v11
`java -version`
Should be : `openjdk version "1.8.0_252"`
Fix:
`sudo apt-get install openjdk-8-jdk`
Don't worry won't overwrite
Then switch to the correct version via
`sudo update-alternatives --config java`
confirm correct output from `java -ver... |
55,436,590 | I am a beginner trying to learn Python. I wrote a program using Geany and would like to build and execute it but I keep getting this error: "The system cannot find the path specified". I believe I added the right info to the Path though:
```
Compile C:\Python373\python -m py_compile "%f"
Execute C:\Python373\python "... | 2019/03/30 | [
"https://Stackoverflow.com/questions/55436590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10286420/"
] | I had the issue as default installation of java was v11
`java -version`
Should be : `openjdk version "1.8.0_252"`
Fix:
`sudo apt-get install openjdk-8-jdk`
Don't worry won't overwrite
Then switch to the correct version via
`sudo update-alternatives --config java`
confirm correct output from `java -ver... | I had to do the following to fix this error on Windows 10:
1. Install JDK 8. I had JDK 12 installed but it did not seem to work with that version.
2. Add Java to my environment variable Path
To add Java to your environment variable Path do the following:
`Go to Computer -> Advanced system settings -> Environment var... |
17,260,338 | I'm trying to deploy a Flask app to Heroku however upon pushing the code I get the error
```
2013-06-23T11:23:59.264600+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
```
I'm not sure what to try, I've tried changing the port from 5000 to 33507, but... | 2013/06/23 | [
"https://Stackoverflow.com/questions/17260338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/970323/"
] | In my Flask app hosted on Heroku, I use this code to start the server:
```py
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
```
When developing locally, this will use port 5000, in production Her... | Your `main.py` script cannot bind to a specific port, it needs to bind to the port number set in the `$PORT` environment variable. Heroku sets the port it wants in that variable prior to invoking your application.
The error you are getting suggests you are binding to a port that is not the one Heroku expects. |
17,260,338 | I'm trying to deploy a Flask app to Heroku however upon pushing the code I get the error
```
2013-06-23T11:23:59.264600+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
```
I'm not sure what to try, I've tried changing the port from 5000 to 33507, but... | 2013/06/23 | [
"https://Stackoverflow.com/questions/17260338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/970323/"
] | In addition to [msiemens](https://stackoverflow.com/users/997063/msiemens)'s answer
```
import os
from run import app as application
if __name__ == '__main__':
port = int(os.environ.get('PORT', 5000))
application.run(host='0.0.0.0', port=port)
```
Your Procfile should specify the port address which in this ... | Your `main.py` script cannot bind to a specific port, it needs to bind to the port number set in the `$PORT` environment variable. Heroku sets the port it wants in that variable prior to invoking your application.
The error you are getting suggests you are binding to a port that is not the one Heroku expects. |
17,260,338 | I'm trying to deploy a Flask app to Heroku however upon pushing the code I get the error
```
2013-06-23T11:23:59.264600+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
```
I'm not sure what to try, I've tried changing the port from 5000 to 33507, but... | 2013/06/23 | [
"https://Stackoverflow.com/questions/17260338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/970323/"
] | Your `main.py` script cannot bind to a specific port, it needs to bind to the port number set in the `$PORT` environment variable. Heroku sets the port it wants in that variable prior to invoking your application.
The error you are getting suggests you are binding to a port that is not the one Heroku expects. | This also fixes the problem of [H20: App boot timeout](https://devcenter.heroku.com/changelog-items/45).
My Procfile looks like this:
```
web: gunicorn -t 150 -c gunicorn_config.py main:app --bind 0.0.0.0:${PORT}
```
and main.py:
```
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
``` |
17,260,338 | I'm trying to deploy a Flask app to Heroku however upon pushing the code I get the error
```
2013-06-23T11:23:59.264600+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
```
I'm not sure what to try, I've tried changing the port from 5000 to 33507, but... | 2013/06/23 | [
"https://Stackoverflow.com/questions/17260338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/970323/"
] | In my Flask app hosted on Heroku, I use this code to start the server:
```py
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
```
When developing locally, this will use port 5000, in production Her... | In addition to [msiemens](https://stackoverflow.com/users/997063/msiemens)'s answer
```
import os
from run import app as application
if __name__ == '__main__':
port = int(os.environ.get('PORT', 5000))
application.run(host='0.0.0.0', port=port)
```
Your Procfile should specify the port address which in this ... |
17,260,338 | I'm trying to deploy a Flask app to Heroku however upon pushing the code I get the error
```
2013-06-23T11:23:59.264600+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
```
I'm not sure what to try, I've tried changing the port from 5000 to 33507, but... | 2013/06/23 | [
"https://Stackoverflow.com/questions/17260338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/970323/"
] | In my Flask app hosted on Heroku, I use this code to start the server:
```py
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
```
When developing locally, this will use port 5000, in production Her... | This also fixes the problem of [H20: App boot timeout](https://devcenter.heroku.com/changelog-items/45).
My Procfile looks like this:
```
web: gunicorn -t 150 -c gunicorn_config.py main:app --bind 0.0.0.0:${PORT}
```
and main.py:
```
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
``` |
17,260,338 | I'm trying to deploy a Flask app to Heroku however upon pushing the code I get the error
```
2013-06-23T11:23:59.264600+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
```
I'm not sure what to try, I've tried changing the port from 5000 to 33507, but... | 2013/06/23 | [
"https://Stackoverflow.com/questions/17260338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/970323/"
] | In addition to [msiemens](https://stackoverflow.com/users/997063/msiemens)'s answer
```
import os
from run import app as application
if __name__ == '__main__':
port = int(os.environ.get('PORT', 5000))
application.run(host='0.0.0.0', port=port)
```
Your Procfile should specify the port address which in this ... | This also fixes the problem of [H20: App boot timeout](https://devcenter.heroku.com/changelog-items/45).
My Procfile looks like this:
```
web: gunicorn -t 150 -c gunicorn_config.py main:app --bind 0.0.0.0:${PORT}
```
and main.py:
```
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
``` |
60,136,547 | I can't figure out how to use multithreading/multiprocessing in python to speed up this scraping process getting all the usernames from the hashtag 'cats' on instagram.
My goal is to make this as fast as possible because currently the process is kinda slow
```
from instaloader import Instaloader
HASHTAG = 'cats'
... | 2020/02/09 | [
"https://Stackoverflow.com/questions/60136547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12867155/"
] | The `LockedIterator` is inspired from [here](https://stackoverflow.com/questions/1131430/are-generators-threadsafe).
```
import threading
from instaloader import Instaloader
class LockedIterator(object):
def __init__(self, it):
self.lock = threading.Lock()
self.it = it.__iter__()
def __iter__... | **Goal is to have an input file and seperated output.txt files, maybe you can help me here to**
It should be something with line 45
And i'm not really advanced so my try may contains some wrong code, I don't know
As an example hashtags for input.txt I used the:
*wqddt & d2deltas*
```
from instaloader import Insta... |
20,763,448 | EDITED HEAVILY with some new information (and a bounty)
I am trying to create a plug in in python for gimp. (on windows)
this page <http://gimpbook.com/scripting/notes.html> suggests running it from the shell, or looking at ~/.xsession-errors
neither work.
I am able to run it from the cmd shell, as
>
> gimp-2.8.e... | 2013/12/24 | [
"https://Stackoverflow.com/questions/20763448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1456530/"
] | >
> 1- can i refresh a plugin without restarting gimp ? (so at least my
> slow-morph will be faster )
>
>
>
You must restart GIMP when you add a script or change register().
No need to restart when changing other parts of the script -- it runs as a separate process and will be re-read from disk each time.
help... | as noted in [How do I output info to the console in a Gimp python script?](https://stackoverflow.com/questions/9955834/how-do-i-output-info-to-the-console-in-a-gimp-python-script/15637932#15637932)
add
```
import sys
sys.stderr = open( 'c:\\temp\\gimpstderr.txt', 'w')
sys.stdout = open( 'c:\\temp\\gimpstdout.txt', ... |
20,763,448 | EDITED HEAVILY with some new information (and a bounty)
I am trying to create a plug in in python for gimp. (on windows)
this page <http://gimpbook.com/scripting/notes.html> suggests running it from the shell, or looking at ~/.xsession-errors
neither work.
I am able to run it from the cmd shell, as
>
> gimp-2.8.e... | 2013/12/24 | [
"https://Stackoverflow.com/questions/20763448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1456530/"
] | >
> 1- can i refresh a plugin without restarting gimp ? (so at least my
> slow-morph will be faster )
>
>
>
You must restart GIMP when you add a script or change register().
No need to restart when changing other parts of the script -- it runs as a separate process and will be re-read from disk each time.
help... | I am a newbie to python, but I would like to give a shout-out, first to winpdb, and then to this comment for integrating winpdb into GIMP.
This same procedure works as well for LibreOffice 4.
If I may be allowed to vent a little; I have a moderate amount of experience with Visual Basic, more or less at a hobbiest lev... |
55,841,631 | So i have a question to create a matrix, but I'm unsure why the values are shared? Not sure if its due to the sequence being a reference type or not?
If you write this code in pythontutor, you'll find that the main tuple all points to the same 'row' tuple and is shared. I understand that if I did `return row*n` it'd b... | 2019/04/25 | [
"https://Stackoverflow.com/questions/55841631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11245768/"
] | The reason why your query isn't working as expected is because you are not actually targeting the specific array element you want to update.
Here's how I would write the query:
```
patients.findOneAndUpdate(
{_id: "5cb939a3ba1d7d693846136c"},
{$set: {"myArray.$[el].value": 424214 } },
{
arrayFilters: [{ "... | Ok i found out and managed to update but the right answer from Frank Rose is better cause it worked in my other projects but not the current one
Because i was using version 4.4 of mongoose, only version 5 and above can use arrayfilter
For mongoose version < 5:
```
patients.findOneAndUpdate(
{
_id: "5cb939a3ba1... |
50,913,172 | Big hello to the Stackoverflow community,
I am trying to read in a .csv file with 1370 rows and two columns: `Time` and `Speed`.
```
Time Speed
0 1
1 4
2 7
3 8
```
I want to find the difference in `Speed` between two time steps (e.g. `Time` `2` and `1`, which is `3`) for the entire len... | 2018/06/18 | [
"https://Stackoverflow.com/questions/50913172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9957516/"
] | You can just use [`pd.Series.diff`](http://pandas.pydata.org/pandas-docs/version/0.22/generated/pandas.Series.diff.html):
```
df['ds'] = df['Speed'].diff()
print(df)
Time Speed ds
0 0 1 NaN
1 1 4 3.0
2 2 7 3.0
3 3 8 1.0
```
The loop method you've attempted is not recom... | Use:
```
df['Speed_avg'] = df['Speed'].rolling(2, min_periods=2).mean()
df['ds'] = df['Speed'].diff()
```
Output:
```
Time Speed Speed_avg ds
0 0 1 NaN NaN
1 1 4 2.5 3.0
2 2 7 5.5 3.0
3 3 8 7.5 1.0
``` |
46,501,292 | I'm building a data extract using [scrapy](https://scrapy.org/) and want to normalize a raw string pulled out of an HTML document. Here's an example string:
```
Sapphire RX460 OC 2/4GB
```
Notice two groups of two whitespaces preceeding the string literal and between `OC` and `2`.
Python provides trim as describ... | 2017/09/30 | [
"https://Stackoverflow.com/questions/46501292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/712334/"
] | You can use:
```
" ".join(s.split())
```
where `s` is your string. | You can use a function like below with regular expression to scan for continuous spaces and replace them by 1 space
```
import re
def clean_data(data):
return re.sub(" {2,}", " ", data.strip())
product_title = clean(product.css('h3::text').extract_first())
```
And then improve clean function anyway you like it |
46,501,292 | I'm building a data extract using [scrapy](https://scrapy.org/) and want to normalize a raw string pulled out of an HTML document. Here's an example string:
```
Sapphire RX460 OC 2/4GB
```
Notice two groups of two whitespaces preceeding the string literal and between `OC` and `2`.
Python provides trim as describ... | 2017/09/30 | [
"https://Stackoverflow.com/questions/46501292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/712334/"
] | Instead of using regex's for this, a more efficient solution is to use the join/split option, observe:
```
>>> timeit.Timer((lambda:' '.join(' Sapphire RX460 OC 2/4GB'.split()))).timeit()
0.7263979911804199
>>> def f():
return re.sub(" +", ' ', " Sapphire RX460 OC 2/4GB").split()
>>> timeit.Timer(f).timei... | You can use a function like below with regular expression to scan for continuous spaces and replace them by 1 space
```
import re
def clean_data(data):
return re.sub(" {2,}", " ", data.strip())
product_title = clean(product.css('h3::text').extract_first())
```
And then improve clean function anyway you like it |
46,501,292 | I'm building a data extract using [scrapy](https://scrapy.org/) and want to normalize a raw string pulled out of an HTML document. Here's an example string:
```
Sapphire RX460 OC 2/4GB
```
Notice two groups of two whitespaces preceeding the string literal and between `OC` and `2`.
Python provides trim as describ... | 2017/09/30 | [
"https://Stackoverflow.com/questions/46501292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/712334/"
] | You can use:
```
" ".join(s.split())
```
where `s` is your string. | Instead of using regex's for this, a more efficient solution is to use the join/split option, observe:
```
>>> timeit.Timer((lambda:' '.join(' Sapphire RX460 OC 2/4GB'.split()))).timeit()
0.7263979911804199
>>> def f():
return re.sub(" +", ' ', " Sapphire RX460 OC 2/4GB").split()
>>> timeit.Timer(f).timei... |
37,336,875 | I have a 2 set of data i crawled from a html table using regex expression
data:
```
<div class = "info">
<div class="name"><td>random</td></div>
<div class="hp"><td>123456</td></div>
<div class="email"><td>[email protected]</td></div>
</div>
<div class = "info">
<div class="name"><td>random123</td><... | 2016/05/20 | [
"https://Stackoverflow.com/questions/37336875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3797825/"
] | You should not be parsing HTML with regex. It's just a mess, do it with BS4. Doing it the right way:
```
soup = BeautifulSoup(match3, "html.parser")
names = []
allTds = soup.find_all("td")
for i,item in enumerate(allTds[::3]):
# firstname hp email
names.append((item.text, allTds[(i*... | As @Racialz pointed out, you should look into [using HTML parsers instead of regular expressions](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags).
Let's take [`BeautifulSoup`](https://www.crummy.com/software/BeautifulSoup/bs4/doc/) as well as @Racialz did, but build ... |
39,679,940 | I have two lists:
```
list1=['lo0','lo1','te123','te234']
list2=['lo0','first','lo1','second','lo2','third','te123','fourth']
```
I want to write a python code to print the next element of list2 where item of list1 is present in list2,else write "no-match",i.e, I want the output as:
```
first
second
no-match
fourth... | 2016/09/24 | [
"https://Stackoverflow.com/questions/39679940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6708941/"
] | You're absolutely right - `messagePolling` is a function. However, `messagePolling()` is *not* a function. You can see that right in your console:
```
// assume messagePolling is a function that doesn't return anything
messagePolling() // -> undefined
```
So, when you do this:
```
setTimeout(messagePolling(), 1000)... | Written as
`setTimeout(messagePolling(),1000)` the function is executed **immediately** and a `setTimeout` is set to call `undefined` (the value returned by your function) after one second. (this should actually throw an error if ran inside Node.js, as `undefined` is not a valid function)
Written as `setTimeout(messa... |
39,679,940 | I have two lists:
```
list1=['lo0','lo1','te123','te234']
list2=['lo0','first','lo1','second','lo2','third','te123','fourth']
```
I want to write a python code to print the next element of list2 where item of list1 is present in list2,else write "no-match",i.e, I want the output as:
```
first
second
no-match
fourth... | 2016/09/24 | [
"https://Stackoverflow.com/questions/39679940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6708941/"
] | Written as
`setTimeout(messagePolling(),1000)` the function is executed **immediately** and a `setTimeout` is set to call `undefined` (the value returned by your function) after one second. (this should actually throw an error if ran inside Node.js, as `undefined` is not a valid function)
Written as `setTimeout(messa... | When you type `messagePolling` you are passing the function to `setTimeout` as a parameter. This is the standard way to use setTimeout.
When you type `messagePolling()` you are executing the function and passing the return value to `setTimeout`
That being said, this code looks odd to me. This function just runs itsel... |
39,679,940 | I have two lists:
```
list1=['lo0','lo1','te123','te234']
list2=['lo0','first','lo1','second','lo2','third','te123','fourth']
```
I want to write a python code to print the next element of list2 where item of list1 is present in list2,else write "no-match",i.e, I want the output as:
```
first
second
no-match
fourth... | 2016/09/24 | [
"https://Stackoverflow.com/questions/39679940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6708941/"
] | Written as
`setTimeout(messagePolling(),1000)` the function is executed **immediately** and a `setTimeout` is set to call `undefined` (the value returned by your function) after one second. (this should actually throw an error if ran inside Node.js, as `undefined` is not a valid function)
Written as `setTimeout(messa... | Anywhere a function name contains "()" it is executed immediately except when it is wrapped in quotes i.e is a string. |
39,679,940 | I have two lists:
```
list1=['lo0','lo1','te123','te234']
list2=['lo0','first','lo1','second','lo2','third','te123','fourth']
```
I want to write a python code to print the next element of list2 where item of list1 is present in list2,else write "no-match",i.e, I want the output as:
```
first
second
no-match
fourth... | 2016/09/24 | [
"https://Stackoverflow.com/questions/39679940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6708941/"
] | You're absolutely right - `messagePolling` is a function. However, `messagePolling()` is *not* a function. You can see that right in your console:
```
// assume messagePolling is a function that doesn't return anything
messagePolling() // -> undefined
```
So, when you do this:
```
setTimeout(messagePolling(), 1000)... | When you type `messagePolling` you are passing the function to `setTimeout` as a parameter. This is the standard way to use setTimeout.
When you type `messagePolling()` you are executing the function and passing the return value to `setTimeout`
That being said, this code looks odd to me. This function just runs itsel... |
39,679,940 | I have two lists:
```
list1=['lo0','lo1','te123','te234']
list2=['lo0','first','lo1','second','lo2','third','te123','fourth']
```
I want to write a python code to print the next element of list2 where item of list1 is present in list2,else write "no-match",i.e, I want the output as:
```
first
second
no-match
fourth... | 2016/09/24 | [
"https://Stackoverflow.com/questions/39679940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6708941/"
] | You're absolutely right - `messagePolling` is a function. However, `messagePolling()` is *not* a function. You can see that right in your console:
```
// assume messagePolling is a function that doesn't return anything
messagePolling() // -> undefined
```
So, when you do this:
```
setTimeout(messagePolling(), 1000)... | Anywhere a function name contains "()" it is executed immediately except when it is wrapped in quotes i.e is a string. |
52,608,069 | a python Newbie here. I am currently trying to figure out how to parse all the msg files I have stored in a specific folder and then save the body text to a csv file.
```
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem(r"C:\Users\XY\Do... | 2018/10/02 | [
"https://Stackoverflow.com/questions/52608069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10445933/"
] | You can try something like this to iterate through every file with '.msg' extension in a directory:
```
import os
pathname = os.fsencode('Pathname as string')
for file in os.listdir(pathname):
filename = os.fsdecode(file)
if filename.endswith(".msg"):
#Do something
continue
else:
... | You can use `pathlib` to iterate over the contents of the directory.
Try this:
```
from pathlib import Path
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
# Assuming \Documents\Email Reader is the directory containg files
for p in Path(r'C:\Users\XY\Documents... |
39,280,060 | So I was messing around in python, and developed a problem.
I start out with a string like the following:
```
a = "1523467aa252aaa98a892a8198aa818a18238aa82938a"
```
For every number, you have to add it to a `sum` variable.Also, with every encounter of a letter, the index iterator must move back 2. My program keeps ... | 2016/09/01 | [
"https://Stackoverflow.com/questions/39280060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6421595/"
] | This part is not doing what you think:
```
for i in a:
if isinstance(a[i], int):
```
Since `i` is an iterator, there is no need to use `a[i]`, it will confuse Python.
Also, since `a` is a string, no element of it will be an `int`, they will all be `string`. You want something like this:
```
for i in a:
if ... | You have a few problems with your code. You don't seem to understand how `for... in` loops work, but @Will already addressed that problem in his answer. Furthermore, you have a misunderstanding of how `isinstance()` works. As the numbers are characters of a string, when you iterate over that string each character will ... |
8,329,601 | I am a beginner in python and cant understand why this is happening:
```
from math import *
print "enter the number"
n=int(raw_input())
d=2
s=0
while d<n :
if n%d==0:
x=math.log(d)
s=s+x
print d
d=d+1
print s,n,float(n)/s
```
Running it in Python and inputing a non prime gives the err... | 2011/11/30 | [
"https://Stackoverflow.com/questions/8329601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/855763/"
] | Change
```
from math import *
```
to
```
import math
```
Using `from X import *` is generally not a good idea as it uncontrollably pollutes the global namespace and could present other difficulties. | You need to `import math` rather than `from math import *`. |
8,329,601 | I am a beginner in python and cant understand why this is happening:
```
from math import *
print "enter the number"
n=int(raw_input())
d=2
s=0
while d<n :
if n%d==0:
x=math.log(d)
s=s+x
print d
d=d+1
print s,n,float(n)/s
```
Running it in Python and inputing a non prime gives the err... | 2011/11/30 | [
"https://Stackoverflow.com/questions/8329601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/855763/"
] | Change
```
from math import *
```
to
```
import math
```
Using `from X import *` is generally not a good idea as it uncontrollably pollutes the global namespace and could present other difficulties. | You did a mistake..
When you wrote :
```
from math import *
# This imports all the functions and the classes from math
# log method is also imported.
# But there is nothing defined with name math
```
So, When you try using `math.log`
It gives you error, so :
replace `math.log` with `log`
Or
replace `from math... |
8,329,601 | I am a beginner in python and cant understand why this is happening:
```
from math import *
print "enter the number"
n=int(raw_input())
d=2
s=0
while d<n :
if n%d==0:
x=math.log(d)
s=s+x
print d
d=d+1
print s,n,float(n)/s
```
Running it in Python and inputing a non prime gives the err... | 2011/11/30 | [
"https://Stackoverflow.com/questions/8329601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/855763/"
] | Change
```
from math import *
```
to
```
import math
```
Using `from X import *` is generally not a good idea as it uncontrollably pollutes the global namespace and could present other difficulties. | How about (when you need only `math.pi`):
```
from math import pi as PI
```
and then use it like `PI` symbol? |
8,329,601 | I am a beginner in python and cant understand why this is happening:
```
from math import *
print "enter the number"
n=int(raw_input())
d=2
s=0
while d<n :
if n%d==0:
x=math.log(d)
s=s+x
print d
d=d+1
print s,n,float(n)/s
```
Running it in Python and inputing a non prime gives the err... | 2011/11/30 | [
"https://Stackoverflow.com/questions/8329601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/855763/"
] | You need to `import math` rather than `from math import *`. | How about (when you need only `math.pi`):
```
from math import pi as PI
```
and then use it like `PI` symbol? |
8,329,601 | I am a beginner in python and cant understand why this is happening:
```
from math import *
print "enter the number"
n=int(raw_input())
d=2
s=0
while d<n :
if n%d==0:
x=math.log(d)
s=s+x
print d
d=d+1
print s,n,float(n)/s
```
Running it in Python and inputing a non prime gives the err... | 2011/11/30 | [
"https://Stackoverflow.com/questions/8329601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/855763/"
] | You did a mistake..
When you wrote :
```
from math import *
# This imports all the functions and the classes from math
# log method is also imported.
# But there is nothing defined with name math
```
So, When you try using `math.log`
It gives you error, so :
replace `math.log` with `log`
Or
replace `from math... | How about (when you need only `math.pi`):
```
from math import pi as PI
```
and then use it like `PI` symbol? |
49,709,826 | I am on Windows 10, and I run the following Python file:
```
import subprocess
subprocess.call("dir")
```
But I get the following error:
```
File "A:/python-tests/subprocess_test.py", line 10, in <module>
subprocess.call(["dir"])
File "A:\anaconda\lib\subprocess.py", line 267, in call
with Popen(*pope... | 2018/04/07 | [
"https://Stackoverflow.com/questions/49709826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3486684/"
] | dir is a command implemented in cmd.exe so there is no dir.exe windows executable. You must call the command through cmd.
```
subprocess.call(['cmd', '/c', 'dir'])
``` | You ***must*** set `shell=True` when calling `dir`, since `dir` isn't an executable (there's no such thing as dir.exe). `dir` is an [internal command](https://www.computerhope.com/jargon/i/intecomm.htm) that was loaded with cmd.exe.
As you can see from the [documentation](https://docs.python.org/dev/library/subprocess... |
48,213,605 | So I have a csv file that looks like this..
```
1 a
2 b
3 c
```
And I want to make it look like this..
```
1 2 3
a b c
```
I'm at a loss for how to do this with python3, anyone have any ideas? Really appreciate it | 2018/01/11 | [
"https://Stackoverflow.com/questions/48213605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8761965/"
] | Are you reading the csv with pandas? you can always use numpy or pandas transpose
```
import numpy as np
ar1 = np.array([[1,2,3], ['a','b','c']])
ar2 = np.transpose(ar1)
Out[22]:
array([['1', 'a'],
['2', 'b'],
['3', 'c']],
dtype='<U11')
``` | As others have mentioned, `pandas` and `transpose()` is the way to go here. Here is an example:
```
import pandas as pd
input_filename = "path/to/file"
# I am using space as the sep because that is what you have shown in the example
# Also, you need header=None since your file doesn't have a header
df = pd.read_csv(... |
5,188,285 | I need to get some debugging libraries/tools to trace back the stack information print out to the stdout.
Python's [traceback](http://docs.python.org/library/traceback.html) library can be an example.
What can be the C++ equivalent to Python's traceback library? | 2011/03/04 | [
"https://Stackoverflow.com/questions/5188285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | This is platform-specific, and also depends on how you're compiling code. If you compile code with gcc using `-fomit-frame-pointer` it's very hard to get a useful backtrace, generally requiring heuristics. If you're using any libraries that use that flag you'll also run into problems--it's often used for heavily optimi... | Try [google core dumper](http://code.google.com/p/google-coredumper/), it will give you a core dump when you need it. |
5,188,285 | I need to get some debugging libraries/tools to trace back the stack information print out to the stdout.
Python's [traceback](http://docs.python.org/library/traceback.html) library can be an example.
What can be the C++ equivalent to Python's traceback library? | 2011/03/04 | [
"https://Stackoverflow.com/questions/5188285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | Try [google core dumper](http://code.google.com/p/google-coredumper/), it will give you a core dump when you need it. | I have had success with [libunwind](http://savannah.nongnu.org/projects/libunwind/) in the past. I know it works well with linux, but not sure how Windows is, although it claims to be portable. |
5,188,285 | I need to get some debugging libraries/tools to trace back the stack information print out to the stdout.
Python's [traceback](http://docs.python.org/library/traceback.html) library can be an example.
What can be the C++ equivalent to Python's traceback library? | 2011/03/04 | [
"https://Stackoverflow.com/questions/5188285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | Try [google core dumper](http://code.google.com/p/google-coredumper/), it will give you a core dump when you need it. | If you are looking for getting a 'stack trace' in case of crash, try '[google breakpad](http://code.google.com/p/google-breakpad/)' |
5,188,285 | I need to get some debugging libraries/tools to trace back the stack information print out to the stdout.
Python's [traceback](http://docs.python.org/library/traceback.html) library can be an example.
What can be the C++ equivalent to Python's traceback library? | 2011/03/04 | [
"https://Stackoverflow.com/questions/5188285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | This is platform-specific, and also depends on how you're compiling code. If you compile code with gcc using `-fomit-frame-pointer` it's very hard to get a useful backtrace, generally requiring heuristics. If you're using any libraries that use that flag you'll also run into problems--it's often used for heavily optimi... | I have had success with [libunwind](http://savannah.nongnu.org/projects/libunwind/) in the past. I know it works well with linux, but not sure how Windows is, although it claims to be portable. |
5,188,285 | I need to get some debugging libraries/tools to trace back the stack information print out to the stdout.
Python's [traceback](http://docs.python.org/library/traceback.html) library can be an example.
What can be the C++ equivalent to Python's traceback library? | 2011/03/04 | [
"https://Stackoverflow.com/questions/5188285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | This is platform-specific, and also depends on how you're compiling code. If you compile code with gcc using `-fomit-frame-pointer` it's very hard to get a useful backtrace, generally requiring heuristics. If you're using any libraries that use that flag you'll also run into problems--it's often used for heavily optimi... | If you are looking for getting a 'stack trace' in case of crash, try '[google breakpad](http://code.google.com/p/google-breakpad/)' |
5,188,285 | I need to get some debugging libraries/tools to trace back the stack information print out to the stdout.
Python's [traceback](http://docs.python.org/library/traceback.html) library can be an example.
What can be the C++ equivalent to Python's traceback library? | 2011/03/04 | [
"https://Stackoverflow.com/questions/5188285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | This is platform-specific, and also depends on how you're compiling code. If you compile code with gcc using `-fomit-frame-pointer` it's very hard to get a useful backtrace, generally requiring heuristics. If you're using any libraries that use that flag you'll also run into problems--it's often used for heavily optimi... | There's now [cpp-traceback](https://code.google.com/p/cpp-traceback/), it's exactly Python-style tracebacks for C++. |
5,188,285 | I need to get some debugging libraries/tools to trace back the stack information print out to the stdout.
Python's [traceback](http://docs.python.org/library/traceback.html) library can be an example.
What can be the C++ equivalent to Python's traceback library? | 2011/03/04 | [
"https://Stackoverflow.com/questions/5188285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | There's now [cpp-traceback](https://code.google.com/p/cpp-traceback/), it's exactly Python-style tracebacks for C++. | I have had success with [libunwind](http://savannah.nongnu.org/projects/libunwind/) in the past. I know it works well with linux, but not sure how Windows is, although it claims to be portable. |
5,188,285 | I need to get some debugging libraries/tools to trace back the stack information print out to the stdout.
Python's [traceback](http://docs.python.org/library/traceback.html) library can be an example.
What can be the C++ equivalent to Python's traceback library? | 2011/03/04 | [
"https://Stackoverflow.com/questions/5188285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | There's now [cpp-traceback](https://code.google.com/p/cpp-traceback/), it's exactly Python-style tracebacks for C++. | If you are looking for getting a 'stack trace' in case of crash, try '[google breakpad](http://code.google.com/p/google-breakpad/)' |
14,962,289 | I am running a django app with nginx & uwsgi. Here's how i run uwsgi:
```
sudo uwsgi -b 25000 --chdir=/www/python/apps/pyapp --module=wsgi:application --env DJANGO_SETTINGS_MODULE=settings --socket=/tmp/pyapp.socket --cheaper=8 --processes=16 --harakiri=10 --max-requests=5000 --vacuum --master --pidfile=/tmp/pyapp-... | 2013/02/19 | [
"https://Stackoverflow.com/questions/14962289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/202690/"
] | **EDIT 1** Seen the comment that you have 1 virtual core, adding commentary through on all relavant points
**EDIT 2** More information from Maverick, so I'm eliminating ideas ruled out and developing the confirmed issues.
**EDIT 3** Filled out more details about uwsgi request queue and scaling options. Improved gramm... | Adding more workers and getting less r/s means that your request "is pure CPU" and there is no IO waits that another worker can use to serve another request.
If you want to scale you will need to use another server with more (or faster) cpu's.
However this is a synthetic test, the number of r/s you get are the upper ... |
14,962,289 | I am running a django app with nginx & uwsgi. Here's how i run uwsgi:
```
sudo uwsgi -b 25000 --chdir=/www/python/apps/pyapp --module=wsgi:application --env DJANGO_SETTINGS_MODULE=settings --socket=/tmp/pyapp.socket --cheaper=8 --processes=16 --harakiri=10 --max-requests=5000 --vacuum --master --pidfile=/tmp/pyapp-... | 2013/02/19 | [
"https://Stackoverflow.com/questions/14962289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/202690/"
] | **EDIT 1** Seen the comment that you have 1 virtual core, adding commentary through on all relavant points
**EDIT 2** More information from Maverick, so I'm eliminating ideas ruled out and developing the confirmed issues.
**EDIT 3** Filled out more details about uwsgi request queue and scaling options. Improved gramm... | Please run benchmarks much longer than a minute (5-10 at least), You really won't get much information from such a short test. And use uWSGI's carbon plugin to push stats to carbon/graphite server (You will need to have one), You will have much more information for debugging.
When You send 500 concurrent requests to Y... |
14,962,289 | I am running a django app with nginx & uwsgi. Here's how i run uwsgi:
```
sudo uwsgi -b 25000 --chdir=/www/python/apps/pyapp --module=wsgi:application --env DJANGO_SETTINGS_MODULE=settings --socket=/tmp/pyapp.socket --cheaper=8 --processes=16 --harakiri=10 --max-requests=5000 --vacuum --master --pidfile=/tmp/pyapp-... | 2013/02/19 | [
"https://Stackoverflow.com/questions/14962289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/202690/"
] | Please run benchmarks much longer than a minute (5-10 at least), You really won't get much information from such a short test. And use uWSGI's carbon plugin to push stats to carbon/graphite server (You will need to have one), You will have much more information for debugging.
When You send 500 concurrent requests to Y... | Adding more workers and getting less r/s means that your request "is pure CPU" and there is no IO waits that another worker can use to serve another request.
If you want to scale you will need to use another server with more (or faster) cpu's.
However this is a synthetic test, the number of r/s you get are the upper ... |
47,943,854 | I'm new to waf build tool and I've googled for answers but very few unhelpful links.
Does anyone know?
As wscript is essentially a python script, I suppose I could use the `os` package? | 2017/12/22 | [
"https://Stackoverflow.com/questions/47943854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5556905/"
] | Don't use the `os` module, instead use the `DEST_*` variables:
```py
ctx.load('compiler_c')
print (ctx.env.DEST_OS, ctx.env.DEST_CPU, ctx.env.DEST_BINFMT)
```
On my machine this would print `('linux', 'x86_64', 'elf')`. Then you can dispatch on that. | You can use `import` at every point where you could use it any other python script.
I prefer using `platform` for programming a function os-agnostic instead on evaluate some attributes of `os`.
Writing the [Build-related commands](https://waf.io/book/#_build_related_commands) example in the [waf book](https://waf.io/... |
37,400,078 | I am trying to translate an if-else statement written in c++ to a corresponding chunk of python code. For a C++ map dpt2, I am attempting to translate:
```
if (dpt2.find(key_t) == dpt2.end()) { dpt2[key_t] = rat; }
else { dpt2.find(key_t) -> second = dpt2.find(key_t) -> second + rat; }
```
I'm not super familiar wit... | 2016/05/23 | [
"https://Stackoverflow.com/questions/37400078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3396878/"
] | First of all, in C++ you'd write that as:
```
dpt[key_t] += rat;
```
That will do only one map lookup - as opposed to the code you wrote which does 2 lookups in the case that `key_t` isn't in the map and 3 lookups in the case that it is.
---
And in Python, you'd write it much the same way - assuming you declare `... | Something like this?
```
dpt2[key_t] = dpt2.get(key_t, 0) + rat
``` |
17,093,322 | I have a large data set of urls and I need a way to parse words from the urls eg:
```
realestatesales.com -> {"real","estate","sales"}
```
I would prefer to do it in python. This seems like it should be possible with some kind of english language dictionary. There might be some ambiguous cases, but I feel like there... | 2013/06/13 | [
"https://Stackoverflow.com/questions/17093322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1893354/"
] | This is a problem is word segmentation, and an efficient dynamic programming solution exists. [This](http://thenoisychannel.com/2011/08/08/retiring-a-great-interview-problem/) page discusses how you could implement it. I have also answered this question on SO before, but I can't find a link to the answer. Please feel f... | This might be of use to you: <http://www.clips.ua.ac.be/pattern>
It's a set of modules which, depending on your system, might already be installed. It does all kinds of interesting stuff, and even if it doesn't do exactly what you need it might get you started on the right path. |
17,093,322 | I have a large data set of urls and I need a way to parse words from the urls eg:
```
realestatesales.com -> {"real","estate","sales"}
```
I would prefer to do it in python. This seems like it should be possible with some kind of english language dictionary. There might be some ambiguous cases, but I feel like there... | 2013/06/13 | [
"https://Stackoverflow.com/questions/17093322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1893354/"
] | This is a problem is word segmentation, and an efficient dynamic programming solution exists. [This](http://thenoisychannel.com/2011/08/08/retiring-a-great-interview-problem/) page discusses how you could implement it. I have also answered this question on SO before, but I can't find a link to the answer. Please feel f... | Ternary Search Trees when filled with a word-dictionary can find the most-complex set of matched terms (*words*) rather efficiently. This is the solution I've previously used.
You can get a C/Python implementation of a tst here: <http://github.com/nlehuen/pytst>
**Example:**
```
import tst
tree = tst.TST()
#note ... |
14,441,412 | I have python scripts and shell scripts in the same folder which both need configuration. I currently have a config.py for my python scripts but I was wondering if it is possible to have a single configuration file which can be easily read by both python scripts and also shell scripts.
Can anyone give an example of th... | 2013/01/21 | [
"https://Stackoverflow.com/questions/14441412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1738522/"
] | I think the simplest solution will be :
```
key1="value1"
key2="value2"
key3="value3"
```
in [shell](/questions/tagged/shell "show questions tagged 'shell'") you just have to source this env file and in Python, it's easy to parse.
Spaces are not allowed around `=`
For Python, see this post : [Emulating Bash 'sourc... | This is valid in both shell and python:
```
NUMBER=42
STRING="Hello there"
```
what else do you need? |
14,441,412 | I have python scripts and shell scripts in the same folder which both need configuration. I currently have a config.py for my python scripts but I was wondering if it is possible to have a single configuration file which can be easily read by both python scripts and also shell scripts.
Can anyone give an example of th... | 2013/01/21 | [
"https://Stackoverflow.com/questions/14441412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1738522/"
] | I think the simplest solution will be :
```
key1="value1"
key2="value2"
key3="value3"
```
in [shell](/questions/tagged/shell "show questions tagged 'shell'") you just have to source this env file and in Python, it's easy to parse.
Spaces are not allowed around `=`
For Python, see this post : [Emulating Bash 'sourc... | **configobj** lib can help with this.
```
from configobj import ConfigObj
cfg = ConfigObj('/home/.aws/config')
access_key_id = cfg['aws_access_key_id']
secret_access_key = cfg['aws_secret_access_key']
``` |
14,441,412 | I have python scripts and shell scripts in the same folder which both need configuration. I currently have a config.py for my python scripts but I was wondering if it is possible to have a single configuration file which can be easily read by both python scripts and also shell scripts.
Can anyone give an example of th... | 2013/01/21 | [
"https://Stackoverflow.com/questions/14441412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1738522/"
] | I think the simplest solution will be :
```
key1="value1"
key2="value2"
key3="value3"
```
in [shell](/questions/tagged/shell "show questions tagged 'shell'") you just have to source this env file and in Python, it's easy to parse.
Spaces are not allowed around `=`
For Python, see this post : [Emulating Bash 'sourc... | Keeping "config.py" rather than "config.sh" leads to some pretty code.
*config.py*
```
CONFIG_VAR = "value"
CONFIG_VAR2 = "value2"
```
*script.py*:
```
import config
CONFIG_VAR = config.CONFIG_VAR
CONFIG_VAR2 = config.CONFIG_VAR2
```
*script.sh*:
```
CONFIG_VAR="$(python-c 'import config;print(config.CONFIG_VA... |
14,441,412 | I have python scripts and shell scripts in the same folder which both need configuration. I currently have a config.py for my python scripts but I was wondering if it is possible to have a single configuration file which can be easily read by both python scripts and also shell scripts.
Can anyone give an example of th... | 2013/01/21 | [
"https://Stackoverflow.com/questions/14441412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1738522/"
] | **configobj** lib can help with this.
```
from configobj import ConfigObj
cfg = ConfigObj('/home/.aws/config')
access_key_id = cfg['aws_access_key_id']
secret_access_key = cfg['aws_secret_access_key']
``` | This is valid in both shell and python:
```
NUMBER=42
STRING="Hello there"
```
what else do you need? |
14,441,412 | I have python scripts and shell scripts in the same folder which both need configuration. I currently have a config.py for my python scripts but I was wondering if it is possible to have a single configuration file which can be easily read by both python scripts and also shell scripts.
Can anyone give an example of th... | 2013/01/21 | [
"https://Stackoverflow.com/questions/14441412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1738522/"
] | This is valid in both shell and python:
```
NUMBER=42
STRING="Hello there"
```
what else do you need? | Keeping "config.py" rather than "config.sh" leads to some pretty code.
*config.py*
```
CONFIG_VAR = "value"
CONFIG_VAR2 = "value2"
```
*script.py*:
```
import config
CONFIG_VAR = config.CONFIG_VAR
CONFIG_VAR2 = config.CONFIG_VAR2
```
*script.sh*:
```
CONFIG_VAR="$(python-c 'import config;print(config.CONFIG_VA... |
14,441,412 | I have python scripts and shell scripts in the same folder which both need configuration. I currently have a config.py for my python scripts but I was wondering if it is possible to have a single configuration file which can be easily read by both python scripts and also shell scripts.
Can anyone give an example of th... | 2013/01/21 | [
"https://Stackoverflow.com/questions/14441412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1738522/"
] | **configobj** lib can help with this.
```
from configobj import ConfigObj
cfg = ConfigObj('/home/.aws/config')
access_key_id = cfg['aws_access_key_id']
secret_access_key = cfg['aws_secret_access_key']
``` | Keeping "config.py" rather than "config.sh" leads to some pretty code.
*config.py*
```
CONFIG_VAR = "value"
CONFIG_VAR2 = "value2"
```
*script.py*:
```
import config
CONFIG_VAR = config.CONFIG_VAR
CONFIG_VAR2 = config.CONFIG_VAR2
```
*script.sh*:
```
CONFIG_VAR="$(python-c 'import config;print(config.CONFIG_VA... |
680,320 | Consider the following skeleton of a models.py for a space conquest game:
```
class Fleet(models.Model):
game = models.ForeignKey(Game, related_name='planet_set')
owner = models.ForeignKey(User, related_name='planet_set', null=True, blank=True)
home = models.ForeignKey(Planet, related_name='departing_fleet... | 2009/03/25 | [
"https://Stackoverflow.com/questions/680320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51100/"
] | Django's ORM does not implement an [identity map](http://en.wikipedia.org/wiki/Identity_map) (it's in the [ticket tracker](http://code.djangoproject.com/ticket/17), but it isn't clear if or when it will be implemented; at least one core Django committer has [expressed opposition to it](http://spreadsheets.google.com/cc... | This is perhaps what you are looking for:
<https://web.archive.org/web/20121126091406/http://simonwillison.net/2009/May/7/mmalones/> |
41,931,719 | I am learning Python and I am reading the "Think Python" and doing some simple exercises included in the book.
I am asked "Define a new function called do\_four that takes a function object and a value and calls the function four times, passing the value as a parameter."
I am trying to compose this function with one ... | 2017/01/30 | [
"https://Stackoverflow.com/questions/41931719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7128498/"
] | `do_twice` gets a function on the first argument, and doesn't return anything. So there is no reason to pass `do_twice` the result of `do_twice`. You need to pass it `a function`.
This would do what you meant:
```
def do_four(f, v):
do_twice(f, v)
do_twice(f, v)
```
Very similar to how you defined `do_twice... | >
>
> ```
> do_twice(do_twice(f, v), v)
> ^^^^^^^^^^^^^^
>
> ```
>
>
Slightly rewritten:
```
result = do_twice(f, v)
do_twice(result, v)
```
You're passing the return value of `do_twice(...)` as the first parameter to `do_twice(...)`. That parameter is supposed to be a function object. `do_twice` does... |
24,029,634 | I ran into this today and can't figure out why. I have several functions chained together that perform some time consuming operations as part of a larger pipeline. I've included these here, pared down to a test example, as best as I could. The issue is that when I call a function directly, I get the expected output (e.... | 2014/06/04 | [
"https://Stackoverflow.com/questions/24029634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1027577/"
] | I solved this one, with a point in the right direction from @mgilson. In fact, it was a random number problem, just not in python - in R (sigh). The state of R is copied when the Pool is created, meaning so is its random seed. To fix, just a little rpy2 as below calling R's set.seed function (with some process specific... | I'm not 100% familiar with these libraries, however, on Linux, (IIRC) `multiprocessing` uses `os.fork`. This means that the state of the random module (which you're using) will also be forked and that each of your processes will generate *the same sequence of random numbers* resulting in a not-so-random `_get_random_st... |
1,770,789 | I'm trying to write a python script which follows the common unix command line pattern of accepting input from stdin if no file name is given. This is what I've been using:
```
if __name__ == "__main__":
if len(sys.argv) > 1:
stream = open(sys.argv[1])
else:
stream = sys.stdin
```
Is there a ... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1770789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/170340/"
] | The [fileinput](http://docs.python.org/library/fileinput.html) module is perfect for this. | similar but one-line solution
```
stream = sys.argv[1] if len(sys.argv)>1 else sys.stdin
``` |
1,770,789 | I'm trying to write a python script which follows the common unix command line pattern of accepting input from stdin if no file name is given. This is what I've been using:
```
if __name__ == "__main__":
if len(sys.argv) > 1:
stream = open(sys.argv[1])
else:
stream = sys.stdin
```
Is there a ... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1770789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/170340/"
] | similar but one-line solution
```
stream = sys.argv[1] if len(sys.argv)>1 else sys.stdin
``` | I would suggest you make it more unixy instead:
```
if len(sys.argv) > 1:
sys.stdin = open(sys.argv[1])
``` |
1,770,789 | I'm trying to write a python script which follows the common unix command line pattern of accepting input from stdin if no file name is given. This is what I've been using:
```
if __name__ == "__main__":
if len(sys.argv) > 1:
stream = open(sys.argv[1])
else:
stream = sys.stdin
```
Is there a ... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1770789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/170340/"
] | similar but one-line solution
```
stream = sys.argv[1] if len(sys.argv)>1 else sys.stdin
``` | how about this one?
```
stream=sys.argv[1:] and open(sys.argv[1]) or sys.stdin
``` |
1,770,789 | I'm trying to write a python script which follows the common unix command line pattern of accepting input from stdin if no file name is given. This is what I've been using:
```
if __name__ == "__main__":
if len(sys.argv) > 1:
stream = open(sys.argv[1])
else:
stream = sys.stdin
```
Is there a ... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1770789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/170340/"
] | The [fileinput](http://docs.python.org/library/fileinput.html) module is perfect for this. | I would suggest you make it more unixy instead:
```
if len(sys.argv) > 1:
sys.stdin = open(sys.argv[1])
``` |
1,770,789 | I'm trying to write a python script which follows the common unix command line pattern of accepting input from stdin if no file name is given. This is what I've been using:
```
if __name__ == "__main__":
if len(sys.argv) > 1:
stream = open(sys.argv[1])
else:
stream = sys.stdin
```
Is there a ... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1770789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/170340/"
] | The [fileinput](http://docs.python.org/library/fileinput.html) module is perfect for this. | how about this one?
```
stream=sys.argv[1:] and open(sys.argv[1]) or sys.stdin
``` |
1,770,789 | I'm trying to write a python script which follows the common unix command line pattern of accepting input from stdin if no file name is given. This is what I've been using:
```
if __name__ == "__main__":
if len(sys.argv) > 1:
stream = open(sys.argv[1])
else:
stream = sys.stdin
```
Is there a ... | 2009/11/20 | [
"https://Stackoverflow.com/questions/1770789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/170340/"
] | how about this one?
```
stream=sys.argv[1:] and open(sys.argv[1]) or sys.stdin
``` | I would suggest you make it more unixy instead:
```
if len(sys.argv) > 1:
sys.stdin = open(sys.argv[1])
``` |
45,703,959 | When trying to deploy an Flask application to my LAMP server, I got an error from [flipflop](https://github.com/Kozea/flipflop), a FastCGI/WSGI gateway which enables my application to speak the FastCGI protocol.
>
> ~/minimal/run.py
>
>
>
```
from flask import Flask
from flipflop import WSGIServer
app = Flask(_... | 2017/08/16 | [
"https://Stackoverflow.com/questions/45703959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5399734/"
] | I've managed to run your example, but there are some tweaking involved to make it work.
You might need to change paths on your system, because from your logs it seems that you're using system that runs `python2.6` and older `apache` version which still uses `httpd` file.
If it is possible I would advise you to up... | You can't run the fastcgi script from the terminal. This script is supposed to be executed by Apache. Typically you have it configured in a `ScriptAlias` directive in your Apache config file. |
45,703,959 | When trying to deploy an Flask application to my LAMP server, I got an error from [flipflop](https://github.com/Kozea/flipflop), a FastCGI/WSGI gateway which enables my application to speak the FastCGI protocol.
>
> ~/minimal/run.py
>
>
>
```
from flask import Flask
from flipflop import WSGIServer
app = Flask(_... | 2017/08/16 | [
"https://Stackoverflow.com/questions/45703959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5399734/"
] | I've managed to run your example, but there are some tweaking involved to make it work.
You might need to change paths on your system, because from your logs it seems that you're using system that runs `python2.6` and older `apache` version which still uses `httpd` file.
If it is possible I would advise you to up... | In general you should use `mod_fastcgi` and configuration simillar to:
```
<VirtualHost *:8091>
ServerName helloworld.local
DocumentRoot /home/fe/work/flipflop
FastCgiServer /home/fe/work/flipflop/run.py
ScriptAlias / /home/fe/work/flipflop/run.py
<Location />
Options none
</Location>
</VirtualHo... |
45,703,959 | When trying to deploy an Flask application to my LAMP server, I got an error from [flipflop](https://github.com/Kozea/flipflop), a FastCGI/WSGI gateway which enables my application to speak the FastCGI protocol.
>
> ~/minimal/run.py
>
>
>
```
from flask import Flask
from flipflop import WSGIServer
app = Flask(_... | 2017/08/16 | [
"https://Stackoverflow.com/questions/45703959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5399734/"
] | I've managed to run your example, but there are some tweaking involved to make it work.
You might need to change paths on your system, because from your logs it seems that you're using system that runs `python2.6` and older `apache` version which still uses `httpd` file.
If it is possible I would advise you to up... | First things first, looks like you're having already some app running/listening on port 5000.
You might want to find which with `sudo sockstat |grep 5000` and then configure Apache consequently, or kill the process/service using `localhost:5000`.
Second, looks like your virtual host is not taken into account/not fully... |
33,874,089 | I am trying to integrate Alipay Gateway with my website using [this](https://github.com/liuyug/django-alipay).
I am getting the payment form but on redirecting to Alipay's website I am getting the `ILLEGAL_PARTNER_EXTERFACE` (pic attached) error.
[](h... | 2015/11/23 | [
"https://Stackoverflow.com/questions/33874089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3442820/"
] | According to the official documentation [here](https://cshall.alipay.com/support/help_detail.htm?help_id=397107), the possible reasons for that error code are:
* You did not apply for this particular payment gateway type
* You did apply for this payment gateway type, but it has not been approved yet
* You did apply fo... | Which you use Alipay gateway API?
It appears you have not applied for the relevant interface privillege or incorrect **partner\_id** param.
Whatever you use anyone language,they just it's based on common http request.
Alipay provides a sandbox enviroment.But them use a common **partner\_id**.
As far as I know none p... |
56,768,320 | It often occurs to me when I try to manipulate data, for example **"UnicodeDecodeError: 'gbk' codec can't decode byte 0x91 in position 2196: illegal multibyte sequence".**
I have found a way to bypass this error but my curiosity drives me to investigate what is in position 2196.
### **Here comes the question**:
How ... | 2019/06/26 | [
"https://Stackoverflow.com/questions/56768320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6632083/"
] | You need to subscribe to the post observable returned by `method` function. It is done like this.
```
this.method().subscribe(
res => {
// Handle success response here
},
err => {
// Handle error response here
}
... | you are getting the 400 bad request error, the payload keys are mis matching with the middle wear. please suggest pass the correct params into Request object. |
56,768,320 | It often occurs to me when I try to manipulate data, for example **"UnicodeDecodeError: 'gbk' codec can't decode byte 0x91 in position 2196: illegal multibyte sequence".**
I have found a way to bypass this error but my curiosity drives me to investigate what is in position 2196.
### **Here comes the question**:
How ... | 2019/06/26 | [
"https://Stackoverflow.com/questions/56768320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6632083/"
] | you should subscribe the post method because this method of http class returns a observable.
you can rewrite your code as:-
```
method() {
const url='/pathname/';
return this.http.post(url, this.Object).subscribe( resp=> {
const data = resp; // response you get from serve
}, error => {
... | you are getting the 400 bad request error, the payload keys are mis matching with the middle wear. please suggest pass the correct params into Request object. |
3,331,850 | I generated a SQL script from a C# application on Windows 7. The name entries have utf8 characters. It works find on Windows machine where I use a python script to populate the db. Now the same script fails on Linux platform complaining about those special characters.
Similar things happened when I generated XML file ... | 2010/07/26 | [
"https://Stackoverflow.com/questions/3331850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/243655/"
] | Please give a small example of a script with "utf8 characters" in the "name entries". Are you sure that they are `utf8` and not some windows encoding like `cp1252'? What makes you sure? Try this in Python at the command prompt:
```
... python -c "print repr(open('small_script.sql', 'rb').read())"
```
The interesting... | Assuming you're using python, make sure you are using [Unicode strings](http://evanjones.ca/python-utf8.html).
For example:
```
s = "Hello world" # Regular String
u = u"Hello Unicode world" # Unicdoe String
```
Edit:
Here's an example of reading from a UTF-8 file from the linked site:
```
import codecs... |
63,397,618 | I'm currently trying to run an application using Docker but get the following error message when I start the application:
```py
error while loading shared libraries: libopencv_highgui.so.4.4: cannot open shared object file: No such file or directory
```
I assume that something is going wrong in the docker file and ... | 2020/08/13 | [
"https://Stackoverflow.com/questions/63397618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13460282/"
] | I was facing the same issue before when installing OpenCV in Docker with Python image. You probably don't need this much dependencies but it's an option. I will have a lightweight version that fits my case. Please give a try for the following code:
**Heavy-loaded version:**
```
FROM python:3.7
RUN apt-get update \
... | ```sh
apt-get update -y
apt install -y libsm6 libxext6
apt update
pip install pyglview
apt install -y libgl1-mesa-glx
``` |
63,397,618 | I'm currently trying to run an application using Docker but get the following error message when I start the application:
```py
error while loading shared libraries: libopencv_highgui.so.4.4: cannot open shared object file: No such file or directory
```
I assume that something is going wrong in the docker file and ... | 2020/08/13 | [
"https://Stackoverflow.com/questions/63397618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13460282/"
] | I also had lots of issues in this process, and found this repository:
<https://github.com/janza/docker-python3-opencv>
Clone or download this and add the additional dependencies and files according to your requirement. | ```sh
apt-get update -y
apt install -y libsm6 libxext6
apt update
pip install pyglview
apt install -y libgl1-mesa-glx
``` |
40,828,531 | This is a little bit a newbie question I know. But however I couldn't find an answer to this question.
I have made some websites that leverage the functionality of automatic emailling. I have made this websites using PHP. Every website I do, in the mailling part, I come accross some "redundancies". Let me give an exam... | 2016/11/27 | [
"https://Stackoverflow.com/questions/40828531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4966877/"
] | First comments on your net's way of working:
* there is no arrow back to the `off` state. So once you switch on your washing machine, won't you never be able to switch it off again ?
* `drain` and `dry` both conduct back to `idle`. But when idle has a token, it will either go to delicate or to T1. The conditions ("pr... | Apparently you're missing some condition to stop the process. Now once you start your washing will continue in an endless loop. |
40,828,531 | This is a little bit a newbie question I know. But however I couldn't find an answer to this question.
I have made some websites that leverage the functionality of automatic emailling. I have made this websites using PHP. Every website I do, in the mailling part, I come accross some "redundancies". Let me give an exam... | 2016/11/27 | [
"https://Stackoverflow.com/questions/40828531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4966877/"
] | First comments on your net's way of working:
* there is no arrow back to the `off` state. So once you switch on your washing machine, won't you never be able to switch it off again ?
* `drain` and `dry` both conduct back to `idle`. But when idle has a token, it will either go to delicate or to T1. The conditions ("pr... | I think it would be nice to leave the transition graphics unshaded or unfilled if it is not enabled. Personally I fill it green if it is enabled.
If you want someone to check if you modeled a logic properly in your Petri Net then it would be nice if you include a description of your system logic in prose. |
48,108,469 | I am doing some PCA using sklearn.decomposition.PCA. I found that if the input matrix X is big, the results of two different PCA instances for PCA.transform will not be the same. For example, when X is a 100x200 matrix, there will not be a problem. When X is a 1000x200 or a 100x2000 matrix, the results of two different... | 2018/01/05 | [
"https://Stackoverflow.com/questions/48108469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7439635/"
] | There's a `svd_solver` param in PCA and by default it has value "auto". Depending on the input data size, it chooses most efficient solver.
Now as for your case, when size is larger than 500, it will choose `randomized`.
>
> svd\_solver : string {‘auto’, ‘full’, ‘arpack’, ‘randomized’}
>
>
> **auto** :
>
>
> th... | I had a similar problem even with the same trial number but on different machines I was getting different result setting the svd\_solver to '`arpack`' solved the problem |
45,890,001 | I want to capture only the lines that end with two asterisks using the following code:
```
import re
total_lines = 0
processed_lines = 0
regexp = re.compile(r'[*][\s]+[*]$')
for line in open('testfile.txt', 'r'):
total_lines += 1
if regexp.search(line):
print'Line not parsed. Format not defined yet'
... | 2017/08/25 | [
"https://Stackoverflow.com/questions/45890001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2579896/"
] | Open the file in universal newline mode `rU` to support I/O on files which have a newline format that is not the native format on the platform in python 2.x, then the $ in your regex will match the EOL.
```
import re
total_lines = 0
processed_lines = 0
regexp = re.compile(r'[*][\s]+[*]$')
for line in open('testfi... | The test file you offered doesn't contain any lines that end with two asterisks?
This regex should match all lines that end with two asterisks:
.\*\\*{2}$ |
62,131,355 | I am trying to create all subset of a given string **recursively**.
Given string = 'aab', we generate all subsets for the characters being distinct.
The answer is: `["", "b", "a", "ab", "ba", "a", "ab", "ba", "aa", "aa", "aab", "aab", "aba", "aba", "baa", "baa"]`.
I have been looking at several solutions such as [this ... | 2020/06/01 | [
"https://Stackoverflow.com/questions/62131355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11469782/"
] | ```
from itertools import *
def recursive_product(s,r=None,i=0):
if r is None:
r = []
if i>len(s):
return r
for c in product(s, repeat=i):
r.append("".join(c))
return recursive_product(s,r,i+1)
print(recursive_product('ab'))
print(recursive_product('abc'))
```
Output:
`['', ... | This is the [powerset](https://stackoverflow.com/questions/1482308/how-to-get-all-subsets-of-a-set-powerset) of the set of characters in the string.
```
from itertools import chain, combinations
s = set('ab') #split string into a set of characters
# combinations gives the elements of the powerset of a given length ... |
62,131,355 | I am trying to create all subset of a given string **recursively**.
Given string = 'aab', we generate all subsets for the characters being distinct.
The answer is: `["", "b", "a", "ab", "ba", "a", "ab", "ba", "aa", "aa", "aab", "aab", "aba", "aba", "baa", "baa"]`.
I have been looking at several solutions such as [this ... | 2020/06/01 | [
"https://Stackoverflow.com/questions/62131355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11469782/"
] | ```
from itertools import *
def recursive_product(s,r=None,i=0):
if r is None:
r = []
if i>len(s):
return r
for c in product(s, repeat=i):
r.append("".join(c))
return recursive_product(s,r,i+1)
print(recursive_product('ab'))
print(recursive_product('abc'))
```
Output:
`['', ... | ```py
import itertools as it
def all_subsets(iterable):
s = list(iterable)
subsets = it.chain.from_iterable(it.permutations(s,r) for r in range(len(s) + 1))
return list(map("".join, list(subsets)))
print(all_subsets('aab'))
# ['', 'a', 'a', 'b', 'aa', 'ab', 'aa', 'ab', 'ba', 'ba', 'aab', 'aba', 'aab', 'ab... |
40,279,577 | using python package "xlsxwriter", I want to highlight cells in the following conditional range;
value > 1 or value <-1
However, some cells have -inf/inf values and it fill colors them too (to yellow). Is thare any way to unhighlight them?
I tried "conditional\_format" function to uncolor them, but it doesn't work. ... | 2016/10/27 | [
"https://Stackoverflow.com/questions/40279577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7079128/"
] | required\_param means that the parameter must exist (or Moodle will throw an immediate, fatal error).
If the parameter is optional, then use optional\_param('name of param', 'default value', PARAM\_TEXT) instead. Then you can check to see if this has the 'default value' (I usually use null as the default value).
In e... | You should compare the result of `required_param('LType',PARAM_ALPHA)` with the value you spect, instead of using isset. For example:
```
if(required_param('LType',PARAM_ALPHA) != 'some value'){
echo "salaam";exit;
}
```
Or:
```
if(required_param('LType',PARAM_ALPHA) === false){
echo "salaam";exit;
}
``` |
54,360,408 | i am writing a python application that is sending continously UDP messages to a predefined network with other hosts and fixed IPs. I wrote the python application and dockerized it. The application works fine in the docker, no problems there.
Unfortunately i am failing to send the UDP messages from my docker to the hos... | 2019/01/25 | [
"https://Stackoverflow.com/questions/54360408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7864140/"
] | So i experimented a lot and i figured out, that i just need to run the docker container with the network configuration as host. The UDP socket in my container is bound to the IP adress of my host and therefore just needs to be linked to the Network of the host. Everyone who is struggeling the same issue, just run
```
... | Build your own bridge
---------------------
1.Configure the new bridge.
```
$ sudo ip link set dev br0 up
$ sudo ip addr add 192.168.5.1/24 dev bridge0
$ sudo ip link set dev bridge0 up
```
Confirm the new bridge’s settings.
```
$ ip addr show bridge0
4: bridge0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state ... |
54,524,124 | I put together a VAE using Dense Neural Networks in Keras. During `model.fit` I get a dimension mismatch, but not sure what is throwing the code off. Below is what my code looks like
```
from keras.layers import Lambda, Input, Dense
from keras.models import Model
from keras.datasets import mnist
from keras.losses impo... | 2019/02/04 | [
"https://Stackoverflow.com/questions/54524124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1491639/"
] | According to [Keras: What if the size of data is not divisible by batch\_size?](https://stackoverflow.com/questions/37974340/keras-what-if-the-size-of-data-is-not-divisible-by-batch-size), one should better use `model.fit_generator` rather than `model.fit` here.
To use `model.fit_generator`, one should define one's ow... | Just tried to replicate and found out that when you define
`x = Input(batch_shape=(batch_size, original_dim))`
you're setting the batch size and it's causing a mismatch when it starts to validate. Change to
```
x = Input(shape=input_shape)
```
and you should be all set. |
30,005,876 | When creating a derived class, what is actually being inherited from `pygame.sprite.Sprite`? It's something that doesn't need to be set up anywhere else in a class, so what is it? Are there actual methods included with it or does python/pygame just know what do with it? | 2015/05/02 | [
"https://Stackoverflow.com/questions/30005876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4515529/"
] | [Use the source, Luke!!!](https://www.youtube.com/watch?v=o2we_B6hDrY) @ [pygame.sprite.Sprite](https://bitbucket.org/pygame/pygame/src/dc57da440ac3415ff679c0e9a1d6d75d949b2db9/lib/sprite.py?at=default#cl-106) inherits `object`
 | Look it up on the original pygame website:
<http://www.pygame.org/docs/ref/sprite.html#pygame.sprite.Sprite> |
14,521,414 | I'm currently working on a small python script, for controlling my home PC (really just a hobby project - nothing serious).
Inside the script, there is two threads running at the same time using thread (might start using threading instead) like this:
```
thread.start_new_thread( Function, (Args) )
```
Its works as ... | 2013/01/25 | [
"https://Stackoverflow.com/questions/14521414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1995290/"
] | Just kill the loader from the main program if it really bothers you. Here's one way to do it.
```
import os
import win32com.client
proc_name = 'MyProgram.exe'
my_pid = os.getpid()
wmi = win32com.client.GetObject('winmgmts:')
all_procs = wmi.InstancesOf('Win32_Process')
for proc in all_procs:
if proc.Properties_(... | Python code does not need to be "compiled with pyinstaller"
Products like "Pyinstaller" or "py2exe" are usefull to create a single executable file that you can distribute to third parties, or relocate inside your computer without worrying about the Python instalation - however, they don add "speed" nor is the resultin... |
49,992,781 | I have the following code in python2. I wanted to know if inheritance works or basic class works if we don't pass 'self' or don't have an init method in the class.
here is the code
```
class Animal:
def whoAmi():
print "Animal"
>>> class Dog(Animal):
pass
...
>>> d= Dog()
>>> d.whoAmi
<boun... | 2018/04/24 | [
"https://Stackoverflow.com/questions/49992781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7406832/"
] | Lets first tackle why doesn't it print "Animal".
The clue is is in the error message:
>
> TypeError: whoAmi() takes no arguments (**1 given**)
>
>
>
When you do `d.whoAmi()`, really what Python is doing is `Dog.whoAmi(d)`. Since your method does not take any arguments, you get that exception.
By convention (as ... | Since you’re are effectively initiating Dog, you’re creating a `self`. So, when you write `d.whoAmi()`, the interpreter inserts `self` as a function argument.
If you tried:
```
d = Dog
d.whoAmi()
```
It should work as expected.
By the way, you should put the decorator `@staticmethod` in he top of your `whoAmi` fun... |
47,261,255 | I'm trying to execute a dag which needs to be run only once. So I placed the dag execution interval as '@once'. However, I'm getting the error as mentioned in this link -
<https://issues.apache.org/jira/browse/AIRFLOW-1400>
Now i'm trying to pass the exact date of execution as below:
```
default_args = {
'owner': 'a... | 2017/11/13 | [
"https://Stackoverflow.com/questions/47261255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7229291/"
] | Grouping by either "TransactionCategory" or "TranCatID" will give you the desired result shown as follows:
```
SELECT TransactionCategory.TransCatName, SUM( `Value`) AS Value FROM Transactions JOIN TransactionCategory on Transactions.TransactionCategory = TransactionCategory.TranCatID GROUP BY TransactionCategory.Tra... | This should do the trick
```
SELECT TransactionCategory.TransCatName,
SUM(Transactions.Value) as Value
FROM Transactions
LEFT JOIN TransactionCategory ON TransactionCategory.TranCatID = Transaction.TransactionCategory
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.