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 |
|---|---|---|---|---|---|
50,305,112 | I am trying to install pandas in my company computer.
I tried to do
```
pip install pandas
```
but operation retries and then timesout.
then I downloaded the package:
pandas-0.22.0-cp27-cp27m-win\_amd64.whl
and install:
```
pip install pandas-0.22.0-cp27-cp27m-win_amd64
```
But I get the following error:
>
>... | 2018/05/12 | [
"https://Stackoverflow.com/questions/50305112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4570833/"
] | This works for me:
```
pip --default-timeout=1000 install pandas
``` | I've fixed this issue on my server by following command because the timeout not helped me.
```
sudo ip link set eth0 mtu 1450
```
In my case problem was in network and ddos protection on my ubuntu 20 server. Hope it'll be helpfull for someone.
More about MTU here <https://ru.wikipedia.org/wiki/Maximum_segment_size> |
50,305,112 | I am trying to install pandas in my company computer.
I tried to do
```
pip install pandas
```
but operation retries and then timesout.
then I downloaded the package:
pandas-0.22.0-cp27-cp27m-win\_amd64.whl
and install:
```
pip install pandas-0.22.0-cp27-cp27m-win_amd64
```
But I get the following error:
>
>... | 2018/05/12 | [
"https://Stackoverflow.com/questions/50305112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4570833/"
] | `PIP` has a default timeout of `15 sec`, [reference guide](https://pip.pypa.io/en/stable/cli/pip/). `Pandas` is a relatively big file, at 10MB, and it's dependant `Numpy`, at 20MB could still be needed (if it is not installed already.). In addition, your network connection may be slow. Therefore, set `PIP` to take long... | In my case, my network was configured to use IPV6 by default, so I changed it to work with IPV4 only.
You can do that in the Network connections section in the control panel:
`'Control Panel\All Control Panel Items\Network Connections'`
[](https://i... |
50,305,112 | I am trying to install pandas in my company computer.
I tried to do
```
pip install pandas
```
but operation retries and then timesout.
then I downloaded the package:
pandas-0.22.0-cp27-cp27m-win\_amd64.whl
and install:
```
pip install pandas-0.22.0-cp27-cp27m-win_amd64
```
But I get the following error:
>
>... | 2018/05/12 | [
"https://Stackoverflow.com/questions/50305112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4570833/"
] | `PIP` has a default timeout of `15 sec`, [reference guide](https://pip.pypa.io/en/stable/cli/pip/). `Pandas` is a relatively big file, at 10MB, and it's dependant `Numpy`, at 20MB could still be needed (if it is not installed already.). In addition, your network connection may be slow. Therefore, set `PIP` to take long... | I've fixed this issue on my server by following command because the timeout not helped me.
```
sudo ip link set eth0 mtu 1450
```
In my case problem was in network and ddos protection on my ubuntu 20 server. Hope it'll be helpfull for someone.
More about MTU here <https://ru.wikipedia.org/wiki/Maximum_segment_size> |
50,305,112 | I am trying to install pandas in my company computer.
I tried to do
```
pip install pandas
```
but operation retries and then timesout.
then I downloaded the package:
pandas-0.22.0-cp27-cp27m-win\_amd64.whl
and install:
```
pip install pandas-0.22.0-cp27-cp27m-win_amd64
```
But I get the following error:
>
>... | 2018/05/12 | [
"https://Stackoverflow.com/questions/50305112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4570833/"
] | In my case, my network was configured to use IPV6 by default, so I changed it to work with IPV4 only.
You can do that in the Network connections section in the control panel:
`'Control Panel\All Control Panel Items\Network Connections'`
[](https://i... | I've fixed this issue on my server by following command because the timeout not helped me.
```
sudo ip link set eth0 mtu 1450
```
In my case problem was in network and ddos protection on my ubuntu 20 server. Hope it'll be helpfull for someone.
More about MTU here <https://ru.wikipedia.org/wiki/Maximum_segment_size> |
37,015,123 | I have a user defined dictionary (sub-classing python's built-in dict object), which does not allow modifying the dict directly:
```
class customDict(dict):
"""
This dict does not allow the direct modification of
its entries(e.g., d['a'] = 5 or del d['a'])
"""
def __init__(self, *args, **kwargs):
... | 2016/05/03 | [
"https://Stackoverflow.com/questions/37015123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3076813/"
] | Your `deepcopy` implementation does not work because the values of `dict` is not stored in `__dict__`. `dict` is a special class. You can make it work calling `__init__` with a deepcopy of the dict.
```
def __deepcopy__(self, memo):
def _deepcopy_dict(x, memo):
y = {}
memo[id(x)] = y
for ke... | Something like this should work without having to change deepcopy.
```
x2 = customList(copy.deepcopy(list(x1)))
```
This will cast `x1` to a `list` deepcopy it then make it a `customList` before assigning to `x2`. |
66,469,499 | I made a memory game in python where players take turn picking two tiles in a grid to see if the revealed letters match.
I used two lists for this, one to store the letters e.g. `letters = ['A', 'A', 'B', 'B']` and the other to record the revealed letters that matches so far in the game e.g. `correctly_revealed = ['A'... | 2021/03/04 | [
"https://Stackoverflow.com/questions/66469499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14026994/"
] | This is indeed Red, Green, Blue, and Alpha, mapped to the 0.0 to 1.0 range, but with an additional transformation as well: These values have been converted from the sRGB colorspace to linear using the [sRGB transfer function](https://en.wikipedia.org/wiki/SRGB). (The back story here is, the [baseColorTexture](https://g... | It is RGBA format, but with numbers between 0 and 1. If you want to insert a color in the Format:
* RGB (255, 255, 255) [=white] divide all values by `255` and use `1` (=fully opaque for the last value
* RGBA (255, 0, 0, 255) [=fully opaque red] divide all components by `255`
Documentation can be found [here](http://... |
64,399,807 | I learning python web automation using selenium but when I trying to add a input for find\_element\_by\_name it is not working.
```
from selenium import webdriver
PATH = 'C:\Program Files (x86)\chromedriver.exe'
driver = webdriver.Chrome(PATH)
driver.get('https://kahoot.it')
codeInput = driver.find_element_by_nam... | 2020/10/17 | [
"https://Stackoverflow.com/questions/64399807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14466617/"
] | First make sure that you spelled it "gameId" and not "gadmeId"
Also import send keys:
```
from selenium.webdriver.common.keys import Keys
```
Then you can send the gameId
```
codeInput = driver.find_element_by_name('gameId')
codeInput.send_keys('202206')
``` | To send value to the input tag.
```
codeInput.send_keys('202206')
```
Also
```
driver.find_element_by_name('gameId')
```
is suppose to be gameId. I would also use a wait after the driver.get() for page loading. |
64,399,807 | I learning python web automation using selenium but when I trying to add a input for find\_element\_by\_name it is not working.
```
from selenium import webdriver
PATH = 'C:\Program Files (x86)\chromedriver.exe'
driver = webdriver.Chrome(PATH)
driver.get('https://kahoot.it')
codeInput = driver.find_element_by_nam... | 2020/10/17 | [
"https://Stackoverflow.com/questions/64399807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14466617/"
] | First make sure that you spelled it "gameId" and not "gadmeId"
Also import send keys:
```
from selenium.webdriver.common.keys import Keys
```
Then you can send the gameId
```
codeInput = driver.find_element_by_name('gameId')
codeInput.send_keys('202206')
``` | Use `send_keys` to send input to the element, otherwise you are running overwriting the variable:
```
codeInput.send_keys('202206')
```
Your assignment to `codeInput` works fine, still check the name attribute correctly. |
61,122,276 | So I've been following Google's official tensorflow guide and trying to build a simple neural network using Keras. But when it comes to training the model, it does not use the entire dataset (with 60000 entries) and instead uses only 1875 entries for training. Any possible fix?
```py
import tensorflow as tf
from tenso... | 2020/04/09 | [
"https://Stackoverflow.com/questions/61122276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5935310/"
] | The number `1875` shown during fitting the model is not the training samples; it is the number of *batches*.
`model.fit` includes an optional argument `batch_size`, which, according to the [documentation](https://www.tensorflow.org/api_docs/python/tf/keras/Model#fit):
>
> If unspecified, `batch_size` will default to... | It does not train on 1875 samples.
```
Epoch 1/10
1875/1875 [===
```
1875 here is the number of steps, not samples. In `fit` method, there is an argument, `batch_size`. The default value for it is `32`. So `1875*32=60000`. The implementation is correct.
If you train it with `batch_size=16`, you will see the number ... |
61,122,276 | So I've been following Google's official tensorflow guide and trying to build a simple neural network using Keras. But when it comes to training the model, it does not use the entire dataset (with 60000 entries) and instead uses only 1875 entries for training. Any possible fix?
```py
import tensorflow as tf
from tenso... | 2020/04/09 | [
"https://Stackoverflow.com/questions/61122276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5935310/"
] | It does not train on 1875 samples.
```
Epoch 1/10
1875/1875 [===
```
1875 here is the number of steps, not samples. In `fit` method, there is an argument, `batch_size`. The default value for it is `32`. So `1875*32=60000`. The implementation is correct.
If you train it with `batch_size=16`, you will see the number ... | Just use batch\_size = 1, if you want the entire 60000 data samples to be visible. |
61,122,276 | So I've been following Google's official tensorflow guide and trying to build a simple neural network using Keras. But when it comes to training the model, it does not use the entire dataset (with 60000 entries) and instead uses only 1875 entries for training. Any possible fix?
```py
import tensorflow as tf
from tenso... | 2020/04/09 | [
"https://Stackoverflow.com/questions/61122276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5935310/"
] | The number `1875` shown during fitting the model is not the training samples; it is the number of *batches*.
`model.fit` includes an optional argument `batch_size`, which, according to the [documentation](https://www.tensorflow.org/api_docs/python/tf/keras/Model#fit):
>
> If unspecified, `batch_size` will default to... | Just use batch\_size = 1, if you want the entire 60000 data samples to be visible. |
24,070,856 | I have a problem with QCheckBox.
I am trying to connect a boolean variable to a QCheckBox so that **when I change the boolean variable, the QCheckBox will be automatically checked or unchecked.**
My Question is similar to the Question below but in opposite way.
[question: Python3 PyQt4 Creating a simple QCheckBox ... | 2014/06/05 | [
"https://Stackoverflow.com/questions/24070856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2727296/"
] | [`property`](https://docs.python.org/2/library/functions.html#property) is the way to define a variable that does additional work upon assigning/accessing. Below is the code modified for that purpose. It changes `ILCheck` to a property such that it'll also update the checkbox upon assigning. Proper error checking for `... | just use `ILCheckbox.setCheckState(Qt.Checked)` after calling ILCheck.
You don't neet signals here since you can call a slot sirectly.
If you want to do use this feature more than once, you should consider writing a setter which changes the state of `self.ILCheck` and emits a signal.
Edit after your clarification:
... |
24,070,856 | I have a problem with QCheckBox.
I am trying to connect a boolean variable to a QCheckBox so that **when I change the boolean variable, the QCheckBox will be automatically checked or unchecked.**
My Question is similar to the Question below but in opposite way.
[question: Python3 PyQt4 Creating a simple QCheckBox ... | 2014/06/05 | [
"https://Stackoverflow.com/questions/24070856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2727296/"
] | As Avaris shows in his/her answer, emulating the overload of operator `=` is a good start for solving the question. But yet still the problem of the code being
added to the `SelectionWindow` class.
But since we are using `Qt`, lets implement a custom `QObject` that represents our "smart" boolean variable which will em... | just use `ILCheckbox.setCheckState(Qt.Checked)` after calling ILCheck.
You don't neet signals here since you can call a slot sirectly.
If you want to do use this feature more than once, you should consider writing a setter which changes the state of `self.ILCheck` and emits a signal.
Edit after your clarification:
... |
24,070,856 | I have a problem with QCheckBox.
I am trying to connect a boolean variable to a QCheckBox so that **when I change the boolean variable, the QCheckBox will be automatically checked or unchecked.**
My Question is similar to the Question below but in opposite way.
[question: Python3 PyQt4 Creating a simple QCheckBox ... | 2014/06/05 | [
"https://Stackoverflow.com/questions/24070856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2727296/"
] | As Avaris shows in his/her answer, emulating the overload of operator `=` is a good start for solving the question. But yet still the problem of the code being
added to the `SelectionWindow` class.
But since we are using `Qt`, lets implement a custom `QObject` that represents our "smart" boolean variable which will em... | [`property`](https://docs.python.org/2/library/functions.html#property) is the way to define a variable that does additional work upon assigning/accessing. Below is the code modified for that purpose. It changes `ILCheck` to a property such that it'll also update the checkbox upon assigning. Proper error checking for `... |
3,014,223 | We build software using Hudson and Maven. We have C#, java and last, but not least PL/SQL sources (sprocs, packages, DDL, crud)
For C# and Java we do unit tests and code analysis, but we don't really know the health of our PL/SQL sources before we actually publish them to the target database.
### Requirements
There ... | 2010/06/10 | [
"https://Stackoverflow.com/questions/3014223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11562/"
] | I think that this blog describes the needed process:
<http://www.theserverlabs.com/blog/?p=435>
Please check and let me know what you think about it. | Our approach is to keep each database object (tables, views, functions, packages, sprocs etc) in its own file under source control and have an integration server ([TeamCity](http://www.jetbrains.com/teamcity/), [Hudson](http://hudson-ci.org/) etc) do a nightly build of the database - from source - where it drops and re... |
3,014,223 | We build software using Hudson and Maven. We have C#, java and last, but not least PL/SQL sources (sprocs, packages, DDL, crud)
For C# and Java we do unit tests and code analysis, but we don't really know the health of our PL/SQL sources before we actually publish them to the target database.
### Requirements
There ... | 2010/06/10 | [
"https://Stackoverflow.com/questions/3014223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11562/"
] | I think that this blog describes the needed process:
<http://www.theserverlabs.com/blog/?p=435>
Please check and let me know what you think about it. | Our [DMS Software Reengineering Toolkit](http://www.semanticdesigns.com/Products/DMS/DMSToolkit.html) is the foundation for arbitrary customizable tools. It has a PL/SQL front end that can be used to build arbitrary source code quality checks. Yes, it has a command-line version.
There are a variety of [PL/SQL COTS too... |
17,410,970 | In my program, many processes can try to create a file if the file doesnt exist currently.
Now I want to ensure that only one of the processes is able to create the file and the rest get an exception if its already been created(kind of process safe and thread safe open() implementation).
How can I achieve this in pyt... | 2013/07/01 | [
"https://Stackoverflow.com/questions/17410970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1421499/"
] | In Python 2.x:
```
import os
fd = os.open('filename', os.O_CREAT|os.O_EXCL)
with os.fdopen(fd, 'w') as f:
....
```
In Python 3.3+:
```
with open('filename', 'x') as f:
....
``` | If you're running on a Unix-like system, open the file like this:
```
f = os.fdopen(os.open(filename, os.O_CREAT | os.O_WRONLY | os.O_EXCL), 'w')
```
The `O_EXCL` flag to `os.open` ensures that the file will only be created (and opened) if it doesn't already exist, otherwise an `OSError` exception will be raised. Th... |
69,499,962 | So I have this big .csv in my work that looks something like this:
```
Name| Adress| Email| Paid Value
John| x street | John@dmail.com| 0|
Chris| c street | Chris@dmail.com| 100|
Rebecca| y street| RebeccaFML|@dmail.com|177|
Bozo | z street| BozoSMH|@yahow.com|976|
```
As you can see, the .csv is seperated by pi... | 2021/10/08 | [
"https://Stackoverflow.com/questions/69499962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14166159/"
] | with subset using `dplyr`
you can use the code below
```
library(dplyr)
df %>% subset(!is.na(value) & bs_Scores != "bs_24" )
``` | A `dplyr` solution:
```r
library(tidyverse)
bs_scores <- tibble::tribble(
~bs_Scores, ~value,
"bs_0", 16.7,
"bs_1", 41.7,
"bs_12", 33.3,
"bs_24", NA,
"bs_0", 25,
"bs_1", 41.7,... |
69,499,962 | So I have this big .csv in my work that looks something like this:
```
Name| Adress| Email| Paid Value
John| x street | John@dmail.com| 0|
Chris| c street | Chris@dmail.com| 100|
Rebecca| y street| RebeccaFML|@dmail.com|177|
Bozo | z street| BozoSMH|@yahow.com|976|
```
As you can see, the .csv is seperated by pi... | 2021/10/08 | [
"https://Stackoverflow.com/questions/69499962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14166159/"
] | Using `base R` with `subset`
```
subset(df1, !((is.na(value) & bs_Scores == 'bs_24')|bs_Scores == ""))
```
-output
```
bs_Scores value
1 bs_0 16.7
2 bs_1 41.7
3 bs_12 33.3
5 bs_0 25.0
6 bs_1 41.7
7 bs_12 NA
8 bs_24 0.0
9 bs_0 16.7
10 bs_1 41.7
11 bs... | A `dplyr` solution:
```r
library(tidyverse)
bs_scores <- tibble::tribble(
~bs_Scores, ~value,
"bs_0", 16.7,
"bs_1", 41.7,
"bs_12", 33.3,
"bs_24", NA,
"bs_0", 25,
"bs_1", 41.7,... |
50,675,758 | Help me please with understanding some of asyncio things.
I want to realize if its possible to do next:
I have synchronous function that for example creates some data in remote API (API can returns success or fail):
```
def sync_func(url):
... do something
return result
```
I have coroutine to run that sync o... | 2018/06/04 | [
"https://Stackoverflow.com/questions/50675758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2235755/"
] | If you create a future (task) out of your coroutine before you shield it, you can always check it later. For example:
```
coro_task = loop.create_task(coro_func(url))
try:
result = await asyncio.wait_for(asyncio.shield(coro_task), API_TIMEOUT)
except asyncio.TimeoutError:
pending_tasks[api_details['api_url']] ... | Ok, thanks @user4815162342 I figured out how to process tasks those were interrupted by timeout - in common my solution now looks like:
```
def sync_func(url):
... do something probably long
return result
async def coro_func(url)
loop = asyncio.get_event_loop()
fn = functools.partial(sync_func, url)
... |
64,341,672 | ```
totalquestions = int(5)
while totalquestions > 0 :
num1 = randint(0,9)
num2 = randint(0,9)
print(num1)
print(num2)
answer = input(str("What is num1 ** num2?"))
if answer == (num1 ** num2):
print("correct")
else:
print("false")
```
I'm trying to create a quiz program whe... | 2020/10/13 | [
"https://Stackoverflow.com/questions/64341672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14444439/"
] | You need to collect the arguments first, *then* pass them to `Person`.
```
def getPeople(num):
people = []
for i in range(num):
name = input("What is the persons name?: ")
age = input("What is the persons age?: ")
computing = input("What is the persons Computing score?: ")
math... | You have added an init method for the class, so you need to pass all those variables as arguments when you call the `Person()` class. As an example:
```
name = input()
age = input()
....
new_person = Person(name, age, ...)
people.append(new_person)
``` |
64,341,672 | ```
totalquestions = int(5)
while totalquestions > 0 :
num1 = randint(0,9)
num2 = randint(0,9)
print(num1)
print(num2)
answer = input(str("What is num1 ** num2?"))
if answer == (num1 ** num2):
print("correct")
else:
print("false")
```
I'm trying to create a quiz program whe... | 2020/10/13 | [
"https://Stackoverflow.com/questions/64341672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14444439/"
] | You need to collect the arguments first, *then* pass them to `Person`.
```
def getPeople(num):
people = []
for i in range(num):
name = input("What is the persons name?: ")
age = input("What is the persons age?: ")
computing = input("What is the persons Computing score?: ")
math... | The arguments to the `__init__()` method specify the arguments you have to supply when you call `Person()` (except that `self` is passed automatically). So you need to pass all the attribute values there, not assign them after creating the person.
```
def getPeople(num):
people = []
for i in range(num):
... |
64,341,672 | ```
totalquestions = int(5)
while totalquestions > 0 :
num1 = randint(0,9)
num2 = randint(0,9)
print(num1)
print(num2)
answer = input(str("What is num1 ** num2?"))
if answer == (num1 ** num2):
print("correct")
else:
print("false")
```
I'm trying to create a quiz program whe... | 2020/10/13 | [
"https://Stackoverflow.com/questions/64341672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14444439/"
] | You need to collect the arguments first, *then* pass them to `Person`.
```
def getPeople(num):
people = []
for i in range(num):
name = input("What is the persons name?: ")
age = input("What is the persons age?: ")
computing = input("What is the persons Computing score?: ")
math... | Did you mean to collect the arguments first and then supply them to the new instance?
```py
def getPeople(num):
people = []
for i in range(num):
name = input("What is the persons name?: ")
age = input("What is the persons age?: ")
computing = input("What is the persons Computing score?... |
39,225,263 | The bottleneck of my code is currently a conversion from a Python list to a C array using ctypes, as described [in this question](https://stackoverflow.com/questions/4145775/how-do-i-convert-a-python-list-into-a-c-array-by-using-ctypes).
A small experiment shows that it is indeed very slow, in comparison of other Pyth... | 2016/08/30 | [
"https://Stackoverflow.com/questions/39225263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4110059/"
] | Here's a little trick, it works for all sorts of situations including yours. But also for trailing comma's for example.
Concept
-------
Instead of printing your text directly, store it in an array like so:
```
$information_to_print = ['col1', 'col2', 'col3'];
$cols = [];
foreach ($information_to_print as $col) {
... | I think this might be easier if the row elements are inside the loop rather than outside. For example here's a quick pseudocode:
```
array items
sum = 0
loop through items
open row
print output for this item
increment sum
if sum is 1
set sum 0
close row
if this is not t... |
18,785,063 | I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have [the error](http://pastebin.com/YQfdYDVK) when installing numpy in the virtualenv.
Maybe, you have any ideas to fix? | 2013/09/13 | [
"https://Stackoverflow.com/questions/18785063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212100/"
] | The problem is `SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.`
so do the following in order to obtain 'Python.h'
make sure apt-get and gcc are up to date
```
sudo apt-get update
sudo apt-get upgrade gcc
```
then install the python2.7-dev
```
sudo apt-get install ... | This is probably because you do not have the `python-dev` package installed. You can install it like this:
```
sudo apt-get install python-dev
```
You can also install it via the Software Center:
 |
18,785,063 | I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have [the error](http://pastebin.com/YQfdYDVK) when installing numpy in the virtualenv.
Maybe, you have any ideas to fix? | 2013/09/13 | [
"https://Stackoverflow.com/questions/18785063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212100/"
] | If you're hitting this issue even though you've installed all OS dependencies (python-devel, fortran compiler, etc), the issue might be instead related to the following bug:
["numpy installation thru install\_requires directive issue..."](http://github.com/numpy/numpy/issues/2434)
Work around is to manually install nu... | @samkhan13 solution didn't work for me as pip said it doesn't have the -E option.
I was still getting the same error, but what worked for me was to install matplotlib, which installed numpy. |
18,785,063 | I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have [the error](http://pastebin.com/YQfdYDVK) when installing numpy in the virtualenv.
Maybe, you have any ideas to fix? | 2013/09/13 | [
"https://Stackoverflow.com/questions/18785063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212100/"
] | The problem is `SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.`
so do the following in order to obtain 'Python.h'
make sure apt-get and gcc are up to date
```
sudo apt-get update
sudo apt-get upgrade gcc
```
then install the python2.7-dev
```
sudo apt-get install ... | If you're hitting this issue even though you've installed all OS dependencies (python-devel, fortran compiler, etc), the issue might be instead related to the following bug:
["numpy installation thru install\_requires directive issue..."](http://github.com/numpy/numpy/issues/2434)
Work around is to manually install nu... |
18,785,063 | I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have [the error](http://pastebin.com/YQfdYDVK) when installing numpy in the virtualenv.
Maybe, you have any ideas to fix? | 2013/09/13 | [
"https://Stackoverflow.com/questions/18785063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212100/"
] | If you're on Python3 you'll need to do `sudo apt-get install python3-dev`. Took me a little while to figure it out. | This is probably because you do not have the `python-dev` package installed. You can install it like this:
```
sudo apt-get install python-dev
```
You can also install it via the Software Center:
 |
18,785,063 | I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have [the error](http://pastebin.com/YQfdYDVK) when installing numpy in the virtualenv.
Maybe, you have any ideas to fix? | 2013/09/13 | [
"https://Stackoverflow.com/questions/18785063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212100/"
] | If you're on Python3 you'll need to do `sudo apt-get install python3-dev`. Took me a little while to figure it out. | This answer is for those of us that compiled python from source or installed it to a non standard directory. In my case, python2.7 was installed to /usr/local and the include files were installed to /usr/local/include/python2.7
```
C_INCLUDE_PATH=/usr/local/include/python2.7:$C_INCLUDE_PATH pip install numpy
``` |
18,785,063 | I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have [the error](http://pastebin.com/YQfdYDVK) when installing numpy in the virtualenv.
Maybe, you have any ideas to fix? | 2013/09/13 | [
"https://Stackoverflow.com/questions/18785063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212100/"
] | If you're on Python3 you'll need to do `sudo apt-get install python3-dev`. Took me a little while to figure it out. | I recently had the same problem. I run Debian Jessie and tried to install numpy from a Python 2.7.9 virtualenv. I got the same error -- numpy complaining that Python.h is missing while python2.7-dev and gcc are already installed.
```
File "numpy/core/setup.py", line 42, in check_types
],
File "numpy/core/setup.py", li... |
18,785,063 | I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have [the error](http://pastebin.com/YQfdYDVK) when installing numpy in the virtualenv.
Maybe, you have any ideas to fix? | 2013/09/13 | [
"https://Stackoverflow.com/questions/18785063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212100/"
] | The problem is `SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.`
so do the following in order to obtain 'Python.h'
make sure apt-get and gcc are up to date
```
sudo apt-get update
sudo apt-get upgrade gcc
```
then install the python2.7-dev
```
sudo apt-get install ... | This answer is for those of us that compiled python from source or installed it to a non standard directory. In my case, python2.7 was installed to /usr/local and the include files were installed to /usr/local/include/python2.7
```
C_INCLUDE_PATH=/usr/local/include/python2.7:$C_INCLUDE_PATH pip install numpy
``` |
18,785,063 | I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have [the error](http://pastebin.com/YQfdYDVK) when installing numpy in the virtualenv.
Maybe, you have any ideas to fix? | 2013/09/13 | [
"https://Stackoverflow.com/questions/18785063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212100/"
] | If you're hitting this issue even though you've installed all OS dependencies (python-devel, fortran compiler, etc), the issue might be instead related to the following bug:
["numpy installation thru install\_requires directive issue..."](http://github.com/numpy/numpy/issues/2434)
Work around is to manually install nu... | This answer is for those of us that compiled python from source or installed it to a non standard directory. In my case, python2.7 was installed to /usr/local and the include files were installed to /usr/local/include/python2.7
```
C_INCLUDE_PATH=/usr/local/include/python2.7:$C_INCLUDE_PATH pip install numpy
``` |
18,785,063 | I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have [the error](http://pastebin.com/YQfdYDVK) when installing numpy in the virtualenv.
Maybe, you have any ideas to fix? | 2013/09/13 | [
"https://Stackoverflow.com/questions/18785063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212100/"
] | The problem is `SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.`
so do the following in order to obtain 'Python.h'
make sure apt-get and gcc are up to date
```
sudo apt-get update
sudo apt-get upgrade gcc
```
then install the python2.7-dev
```
sudo apt-get install ... | @samkhan13 solution didn't work for me as pip said it doesn't have the -E option.
I was still getting the same error, but what worked for me was to install matplotlib, which installed numpy. |
18,785,063 | I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have [the error](http://pastebin.com/YQfdYDVK) when installing numpy in the virtualenv.
Maybe, you have any ideas to fix? | 2013/09/13 | [
"https://Stackoverflow.com/questions/18785063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212100/"
] | If you're hitting this issue even though you've installed all OS dependencies (python-devel, fortran compiler, etc), the issue might be instead related to the following bug:
["numpy installation thru install\_requires directive issue..."](http://github.com/numpy/numpy/issues/2434)
Work around is to manually install nu... | This is probably because you do not have the `python-dev` package installed. You can install it like this:
```
sudo apt-get install python-dev
```
You can also install it via the Software Center:
 |
22,099,882 | I need some help with the encoding of a list. I'm new in python, sorry.
First, I'm using Python 2.7.3
I have two lists (entidad & valores), and I need to get them encoded or something of that.
My code:
```
import urllib
from bs4 import BeautifulSoup
import csv
sock = urllib.urlopen("http://www.fatm.com.es/Datos_Equ... | 2014/02/28 | [
"https://Stackoverflow.com/questions/22099882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3361555/"
] | You should encode your data to utf-8 manually, csv.writer didnt do it for you:
```
w.writerow([s.encode("utf-8") for s in header])
w.writerow([s.encode("utf-8") for s in values])
#w.writerow(header)
#w.writerow(values)
``` | This appears to be the same type of problem as had been found here [UnicodeEncodeError in csv writer in Python](http://love-python.blogspot.com/2012/04/unicodeencodeerror-in-csv-writer-in.html)
>
> UnicodeEncodeError in csv writer in Python
>
> Today I was writing a
> program that generates a csv file after some... |
41,286,526 | I am trying to setup a queue listener for laravel and cannot seem to get supervisor working correctly. I get the following error when I run `supervisorctl reload`:
`error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228`
The file DOES exist. If try to run `sud... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41286526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965066/"
] | You should run `sudo service supervisor start` when you are in the supervisor dir.
Worked for me. | I had a very similar problem (Ubuntu 18.04) and searched similar threads to no avail so answering here with some more comprehensive answers.
Lack of a sock file or socket error is only an indicator that supervisor is not running. If a simple restart doesn't work its either 1. not installed, or 2. failing to start. In ... |
41,286,526 | I am trying to setup a queue listener for laravel and cannot seem to get supervisor working correctly. I get the following error when I run `supervisorctl reload`:
`error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228`
The file DOES exist. If try to run `sud... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41286526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965066/"
] | None of about answers helped me.
the problem was i didn't follow [supervisor documentation](http://supervisord.org/installing.html).
and a step i didn't do was run `echo_supervisord_conf` command that makes the configuration file.
****Steps i did for**** **Ubuntu 18.04:**
**Installing supervisor (without pip):**
1. ... | Check the *supervisord.conf* file.
Look for the following:
```
[unix_http_server]
file=/path/to/supervisor.sock/file ; (the path to the socket file)
chmod=0700 ; sockef file mode(default 0700)
```
Go to the path mentioned above and check if the file is present.
If it is present th... |
41,286,526 | I am trying to setup a queue listener for laravel and cannot seem to get supervisor working correctly. I get the following error when I run `supervisorctl reload`:
`error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228`
The file DOES exist. If try to run `sud... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41286526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965066/"
] | You can try by removing all of the related folder of supervisor & uninstall supervisor completely.
```
sudo rm -rf /var/log/supervisor/supervisord.log
sudo rm -rf /etc/supervisor/conf.d/
```
After doing this, reinstall supervisor by
```
sudo apt install supervisor
```
Now, you can run correctly. Check with
```... | Check the *supervisord.conf* file.
Look for the following:
```
[unix_http_server]
file=/path/to/supervisor.sock/file ; (the path to the socket file)
chmod=0700 ; sockef file mode(default 0700)
```
Go to the path mentioned above and check if the file is present.
If it is present th... |
41,286,526 | I am trying to setup a queue listener for laravel and cannot seem to get supervisor working correctly. I get the following error when I run `supervisorctl reload`:
`error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228`
The file DOES exist. If try to run `sud... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41286526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965066/"
] | I had a very similar problem (Ubuntu 18.04) and searched similar threads to no avail so answering here with some more comprehensive answers.
Lack of a sock file or socket error is only an indicator that supervisor is not running. If a simple restart doesn't work its either 1. not installed, or 2. failing to start. In ... | Facing the `python file not found an error, code=exited, status=2` once I try with the official document but still same.
I have tried so many solutions for my laravel application.
But at last, I have tried with my solution.
Here is an example for the code :
```
[program:dev-worker]
process_name=%(program_name)s_%(pr... |
41,286,526 | I am trying to setup a queue listener for laravel and cannot seem to get supervisor working correctly. I get the following error when I run `supervisorctl reload`:
`error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228`
The file DOES exist. If try to run `sud... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41286526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965066/"
] | I had a very similar problem (Ubuntu 18.04) and searched similar threads to no avail so answering here with some more comprehensive answers.
Lack of a sock file or socket error is only an indicator that supervisor is not running. If a simple restart doesn't work its either 1. not installed, or 2. failing to start. In ... | If by running `sudo service supervisor status` you get the following:
`ExecStart=/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf (code=exited, status=2)`
Try running `/usr/bin/supervisord`, it will give you clear message to tell you where the error is. |
41,286,526 | I am trying to setup a queue listener for laravel and cannot seem to get supervisor working correctly. I get the following error when I run `supervisorctl reload`:
`error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228`
The file DOES exist. If try to run `sud... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41286526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965066/"
] | On Centos 7 I use the following...
```
supervisord -c /path/to/supervisord.conf
```
followed by...
```
supervisorctl -c /path/to/supervisord.conf
```
This gets rid of the ".sock file not found" error. Now you have to kill old processes using...
```
ps aux|grep gunicorn
```
Kill the offending processes using...... | I ran into this issue because we were using supervisorctl to manage gunicorn. The root of my problem had nothing to do with supervisor (it was handling other processes just fine) or the python sock.py file (file was there, permissions were correct), but rather the gunicorn config file `/etc/supervisor/conf.d/gunicorn.c... |
41,286,526 | I am trying to setup a queue listener for laravel and cannot seem to get supervisor working correctly. I get the following error when I run `supervisorctl reload`:
`error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228`
The file DOES exist. If try to run `sud... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41286526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965066/"
] | I had a very similar problem (Ubuntu 18.04) and searched similar threads to no avail so answering here with some more comprehensive answers.
Lack of a sock file or socket error is only an indicator that supervisor is not running. If a simple restart doesn't work its either 1. not installed, or 2. failing to start. In ... | I ran into this issue because we were using supervisorctl to manage gunicorn. The root of my problem had nothing to do with supervisor (it was handling other processes just fine) or the python sock.py file (file was there, permissions were correct), but rather the gunicorn config file `/etc/supervisor/conf.d/gunicorn.c... |
41,286,526 | I am trying to setup a queue listener for laravel and cannot seem to get supervisor working correctly. I get the following error when I run `supervisorctl reload`:
`error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228`
The file DOES exist. If try to run `sud... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41286526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965066/"
] | You should run `sudo service supervisor start` when you are in the supervisor dir.
Worked for me. | >
> Source of answer : <http://supervisord.org/installing.html>
>
>
>
1. Run command : `echo_supervisord_conf`
2. Once you see the file echoed to your terminal, reinvoke the command as `echo_supervisord_conf > /etc/supervisord.conf`. This won’t work if you do not have root access.
3. If you don’t have root access,... |
41,286,526 | I am trying to setup a queue listener for laravel and cannot seem to get supervisor working correctly. I get the following error when I run `supervisorctl reload`:
`error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228`
The file DOES exist. If try to run `sud... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41286526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965066/"
] | I had a very similar problem (Ubuntu 18.04) and searched similar threads to no avail so answering here with some more comprehensive answers.
Lack of a sock file or socket error is only an indicator that supervisor is not running. If a simple restart doesn't work its either 1. not installed, or 2. failing to start. In ... | I did the following to solve the issue on CentOS Linux 7
```
sudo systemctl status supervisord.service
```
With the above command, I realise that the program was in active
```
sudo systemctl start supervisord.service
```
Now I use the command above to start the service and everything works well now |
41,286,526 | I am trying to setup a queue listener for laravel and cannot seem to get supervisor working correctly. I get the following error when I run `supervisorctl reload`:
`error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228`
The file DOES exist. If try to run `sud... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41286526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965066/"
] | >
> **2020 UPDATE**
>
>
> Try running `sudo service supervisor start` in your terminal before using the below solution. I found out that the issue sometimes occurs when `supervisor` is not running, nothing complicated.
>
>
>
I am using `Ubuntu 18.04`. I had the same problem and re-installing supervisor did not s... | I had a very similar problem (Ubuntu 18.04) and searched similar threads to no avail so answering here with some more comprehensive answers.
Lack of a sock file or socket error is only an indicator that supervisor is not running. If a simple restart doesn't work its either 1. not installed, or 2. failing to start. In ... |
18,995,555 | I'm trying check whether the short int have digits that contains in long int. Instead this came out:
```
long int: 198381998
short int: 19
Found a match at 0
Found a match at 1
Found a match at 2
Found a match at 3
Found a match at 4
Found a match at 5
Found a match at 6
Found a match at 7
```
It's s... | 2013/09/25 | [
"https://Stackoverflow.com/questions/18995555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2811732/"
] | You're passing `allData` as an argument to the mapping, but it isn't defined anywhere. You want `data.users` instead (*not* `data` because then `ko.mapping.fromJSON` will return a single object with one key, `users` whose value will be an `observableArray`; you'll confuse Knockout if you try to use that object as the v... | Switching to this .ajax call seemed to resolve the issue.
```
// Load initial state from server, convert it to User instances, then populate self.users
$.ajax({
url: '/sws/users/index',
dataType: 'json',
type: 'POST',
success: function (data) {
self.users(data['users']);... |
63,087,586 | In my views.py file of my Django application I'm trying to load the 'transformers' library with the following command:
```
from transformers import pipeline
```
This works in my local environment, but on my Linux server at Linode, when I try to load my website, the page tries to load for 5 minutes then I get a Timeo... | 2020/07/25 | [
"https://Stackoverflow.com/questions/63087586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4823067/"
] | Maybe you just have to create or update your *requirements.txt* file.
Here is the command : `pip freeze > requirements.txt` | Based on this [answer](https://serverfault.com/a/514251)
>
> Some third party packages for Python which use C extension modules, and this includes scipy and numpy, will only work in the Python main interpreter and cannot be used in sub interpreters as mod\_wsgi by default uses.
>
>
>
`transformers` library uses n... |
23,728,065 | I have been banging my head against the wall with this for long enough that I am okay to turn here at this point.
I have a page with iframe:
```
<iframe frameborder="0" allowtransparency="true" tabindex="0" src="" title="Rich text editor, listing_description" aria-describedby="cke_18" style="width:100%;height:100%">
... | 2014/05/19 | [
"https://Stackoverflow.com/questions/23728065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/360826/"
] | you need Wget for Windows, you can download it from here <http://gnuwin32.sourceforge.net/packages/wget.htm>
open notepad and paste your code, save as "myscript.bat"
make sure it doesn't have .txt
put your "myscript.bat" in the same folder with wget.exe
now try it, it should work | For a newer firmware version, U need to add referer and user-agent. Try this, work for me:
```
wget -qO- --user=admin --password=admin --referer http://192.168.0.1 --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0" http://192.168.0.1/userRpm/SysRebootRpm.htm?Reboot=Reboot
... |
55,603,451 | I am trying to make a program that analyzes stocks, and right now I wrote a simple python script to plot moving averages. Extracting the CSV file from the native path works fine, but when I get it from the web, it doesn't work. Keeps displaying an error: 'list' object has no attribute 'Date'
It worked fine with .CSV, ... | 2019/04/10 | [
"https://Stackoverflow.com/questions/55603451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11337553/"
] | The data got placed in a (one-element) list.
If you do this, after the `read_html` call, it should work:
```
df = df[0]
``` | Did you mean to access the Date feature from the DataFrame object?
If that is the case, then change:
`python x = df.Date` to `python x = df['Date']`
`python y = df.Close` to `python y = df['Close']`
EDIT:
Also: `python df.plot(x='Date', y='Close', style='o')` works instead of plt.plot |
3,949,727 | For code:
```
#!/usr/bin/python
src = """
print '!!!'
import os
"""
obj = compile(src, '', 'exec')
eval(obj, {'__builtins__': False})
```
I get output:
```
!!!
Traceback (most recent call last):
File "./test.py", line 9, in <module>
eval(obj, {'__builtins__': False})
File "", line 3, in <module>
ImportEr... | 2010/10/16 | [
"https://Stackoverflow.com/questions/3949727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23712/"
] | The `__import__` method is invoked by the `import` keyword: [python.org](http://docs.python.org/library/functions.html?highlight=import#__import__)
If you want to be able to import a module you need to leave the `__import__` method in the builtins:
```
src = """
print '!!!'
import os
"""
obj = compile(src, '', 'exe... | In your `eval` the call to `import` is made successfully however `import` makes use of the `__import__` method in builtins which you have made unavailable in your `exec`. This is the reason why you are seeing
```
ImportError: __import__ not found
```
`print` doesn't depend on any builtins so works OK.
You could pas... |
3,949,727 | For code:
```
#!/usr/bin/python
src = """
print '!!!'
import os
"""
obj = compile(src, '', 'exec')
eval(obj, {'__builtins__': False})
```
I get output:
```
!!!
Traceback (most recent call last):
File "./test.py", line 9, in <module>
eval(obj, {'__builtins__': False})
File "", line 3, in <module>
ImportEr... | 2010/10/16 | [
"https://Stackoverflow.com/questions/3949727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23712/"
] | In your `eval` the call to `import` is made successfully however `import` makes use of the `__import__` method in builtins which you have made unavailable in your `exec`. This is the reason why you are seeing
```
ImportError: __import__ not found
```
`print` doesn't depend on any builtins so works OK.
You could pas... | print works because you specified `'exec'` to the `compile` function call. |
3,949,727 | For code:
```
#!/usr/bin/python
src = """
print '!!!'
import os
"""
obj = compile(src, '', 'exec')
eval(obj, {'__builtins__': False})
```
I get output:
```
!!!
Traceback (most recent call last):
File "./test.py", line 9, in <module>
eval(obj, {'__builtins__': False})
File "", line 3, in <module>
ImportEr... | 2010/10/16 | [
"https://Stackoverflow.com/questions/3949727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23712/"
] | In your `eval` the call to `import` is made successfully however `import` makes use of the `__import__` method in builtins which you have made unavailable in your `exec`. This is the reason why you are seeing
```
ImportError: __import__ not found
```
`print` doesn't depend on any builtins so works OK.
You could pas... | `import` calls the global/builtin `__import__` function; if there isn't one to be found, `import` fails.
`print` does not rely on any globals to do its work. That is why `print` works in your example, even though you do not use the available `__builtins__`. |
3,949,727 | For code:
```
#!/usr/bin/python
src = """
print '!!!'
import os
"""
obj = compile(src, '', 'exec')
eval(obj, {'__builtins__': False})
```
I get output:
```
!!!
Traceback (most recent call last):
File "./test.py", line 9, in <module>
eval(obj, {'__builtins__': False})
File "", line 3, in <module>
ImportEr... | 2010/10/16 | [
"https://Stackoverflow.com/questions/3949727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23712/"
] | The `__import__` method is invoked by the `import` keyword: [python.org](http://docs.python.org/library/functions.html?highlight=import#__import__)
If you want to be able to import a module you need to leave the `__import__` method in the builtins:
```
src = """
print '!!!'
import os
"""
obj = compile(src, '', 'exe... | print works because you specified `'exec'` to the `compile` function call. |
3,949,727 | For code:
```
#!/usr/bin/python
src = """
print '!!!'
import os
"""
obj = compile(src, '', 'exec')
eval(obj, {'__builtins__': False})
```
I get output:
```
!!!
Traceback (most recent call last):
File "./test.py", line 9, in <module>
eval(obj, {'__builtins__': False})
File "", line 3, in <module>
ImportEr... | 2010/10/16 | [
"https://Stackoverflow.com/questions/3949727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23712/"
] | The `__import__` method is invoked by the `import` keyword: [python.org](http://docs.python.org/library/functions.html?highlight=import#__import__)
If you want to be able to import a module you need to leave the `__import__` method in the builtins:
```
src = """
print '!!!'
import os
"""
obj = compile(src, '', 'exe... | `import` calls the global/builtin `__import__` function; if there isn't one to be found, `import` fails.
`print` does not rely on any globals to do its work. That is why `print` works in your example, even though you do not use the available `__builtins__`. |
26,797,378 | I'm developing an aplication built on the python Bottle framework. It's amazing and i want to host it somewhere, but of course i need a service where i can run the server.
What are the best options available (on costs too)?
Thanks! | 2014/11/07 | [
"https://Stackoverflow.com/questions/26797378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2344954/"
] | I work for [PythonAnywhere](http://www.pythonanywhere.com/), a Python hosting company, so obviously I think we have a great Bottle hosting solution -- check it out :-)
Some of our competitors -- ones where we feel proud if a customer leaves them to move to us, or where we don't feel too depressed if they leave us to g... | The easiest way to host is use Ngrok ,its an open source tool where use get a temporary link where you can access your local host server on any machine through that link .you can download it from here <https://ngrok.com/> |
12,667,057 | I want my Python program to be deterministic, so I have been using `OrderedDicts` extensively throughout the code. Unfortunately, while debugging memory leaks today, I discovered that OrderedDicts have a custom `__del__` method, making them uncollectable whenever there's a cycle. It's rather unfortunate that there's no... | 2012/10/01 | [
"https://Stackoverflow.com/questions/12667057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1420279/"
] | If the presence of the \_\_del\_\_ method is problematic for you, just remove it:
```
>>> import collections
>>> del collections.OrderedDict.__del__
```
You will gain the ability to use OrderedDicts in a reference cycle. You will lose having the OrderedDict free all its resources immediately upon deletion. | It sounds like you've tracked down a bug in `OrderedDict` that was fixed at some point after your version of 2.7. If it wasn't in any actual released versions, maybe you can just ignore it. But otherwise, yeah, you need a workaround.
I would suggest that, instead of monkeypatching `collections.OrderedDict`, you should... |
12,667,057 | I want my Python program to be deterministic, so I have been using `OrderedDicts` extensively throughout the code. Unfortunately, while debugging memory leaks today, I discovered that OrderedDicts have a custom `__del__` method, making them uncollectable whenever there's a cycle. It's rather unfortunate that there's no... | 2012/10/01 | [
"https://Stackoverflow.com/questions/12667057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1420279/"
] | It sounds like you've tracked down a bug in `OrderedDict` that was fixed at some point after your version of 2.7. If it wasn't in any actual released versions, maybe you can just ignore it. But otherwise, yeah, you need a workaround.
I would suggest that, instead of monkeypatching `collections.OrderedDict`, you should... | Note that [the fix made in Python 2.7](https://github.com/python/cpython/commit/2039753a9ab9d41375ba17877e231e8d53e17749#diff-52502c75edd9dd62aa7a817dbab542d2) to eliminate the `__del__` method and so stop them from being uncollectable does unfortunately mean that every use of an `OrderedDict` (even an empty one) resul... |
12,667,057 | I want my Python program to be deterministic, so I have been using `OrderedDicts` extensively throughout the code. Unfortunately, while debugging memory leaks today, I discovered that OrderedDicts have a custom `__del__` method, making them uncollectable whenever there's a cycle. It's rather unfortunate that there's no... | 2012/10/01 | [
"https://Stackoverflow.com/questions/12667057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1420279/"
] | If the presence of the \_\_del\_\_ method is problematic for you, just remove it:
```
>>> import collections
>>> del collections.OrderedDict.__del__
```
You will gain the ability to use OrderedDicts in a reference cycle. You will lose having the OrderedDict free all its resources immediately upon deletion. | Note that [the fix made in Python 2.7](https://github.com/python/cpython/commit/2039753a9ab9d41375ba17877e231e8d53e17749#diff-52502c75edd9dd62aa7a817dbab542d2) to eliminate the `__del__` method and so stop them from being uncollectable does unfortunately mean that every use of an `OrderedDict` (even an empty one) resul... |
63,336,512 | I have a python flask application which uses tabula internally to extract tables from pdf files.After I do 'cf push' and run the application on PCF,i load the pdf file to the application to read the table. When the app tries to extract the tabular data,I get the below error.
```
2020-08-10T13:38:40.135+05:30 [APP/PROC... | 2020/08/10 | [
"https://Stackoverflow.com/questions/63336512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12403005/"
] | This is a java path error. Your python runtime is not able to find java at all. You need to ensure that your export java in your export path variables. If you are running this process on linux, you can export `export PATH=<your java bin dir>:$PATH` | The highlights:
* You need multiple buildpacks, one for Java and one for Python
* You want to use apt-buildpack, not the Java buildpack though
* You need to set PATH to point to the location where the apt-buildpack installs Java (or have your app look for Java in this specific place)
* You can set PATH in a `.profile`... |
27,718,277 | Well I have an assignment to implement DES and I chose python, only problem is I can't figure out how to XOR bits of a String or Byte String, I can manually XOR them if only I can manage to read the 1s and 0s in them.
Example:
```
s1 = b'abc'
s2 = b'efg'
s3 = XOR(s1,s2) // my own method
```
How can I XOR them or ... | 2014/12/31 | [
"https://Stackoverflow.com/questions/27718277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3417451/"
] | First you need to `zip` your strings then use `ord` (in `python 2`) and `^` for each of characters :
```
>>> s1 = b'abc'
>>> s2 = b'efg'
>>> ''.join(chr(ord(i)^ord(j)) for i,j in zip(s1,s2))
'\x04\x04\x04'
```
the [`ord()`](https://docs.python.org/2/library/functions.html#ord) function retuen value of the byte when ... | ```
>>> b''.join(chr(ord(a) ^ ord(b)) for a, b in zip(b'abc', b'efg'))
'\x04\x04\x04'
``` |
27,718,277 | Well I have an assignment to implement DES and I chose python, only problem is I can't figure out how to XOR bits of a String or Byte String, I can manually XOR them if only I can manage to read the 1s and 0s in them.
Example:
```
s1 = b'abc'
s2 = b'efg'
s3 = XOR(s1,s2) // my own method
```
How can I XOR them or ... | 2014/12/31 | [
"https://Stackoverflow.com/questions/27718277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3417451/"
] | ```
>>> b''.join(chr(ord(a) ^ ord(b)) for a, b in zip(b'abc', b'efg'))
'\x04\x04\x04'
``` | Not really efficient, but this should work.
```
s1 = b'abc'
s2 = b'efg'
s3= b''
for c1,c2 in zip(s1, s2):
s3 += chr( ord(c1) ^ ord(c2) )
>>> s3
'\x04\x04\x04'
``` |
27,718,277 | Well I have an assignment to implement DES and I chose python, only problem is I can't figure out how to XOR bits of a String or Byte String, I can manually XOR them if only I can manage to read the 1s and 0s in them.
Example:
```
s1 = b'abc'
s2 = b'efg'
s3 = XOR(s1,s2) // my own method
```
How can I XOR them or ... | 2014/12/31 | [
"https://Stackoverflow.com/questions/27718277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3417451/"
] | First you need to `zip` your strings then use `ord` (in `python 2`) and `^` for each of characters :
```
>>> s1 = b'abc'
>>> s2 = b'efg'
>>> ''.join(chr(ord(i)^ord(j)) for i,j in zip(s1,s2))
'\x04\x04\x04'
```
the [`ord()`](https://docs.python.org/2/library/functions.html#ord) function retuen value of the byte when ... | Not really efficient, but this should work.
```
s1 = b'abc'
s2 = b'efg'
s3= b''
for c1,c2 in zip(s1, s2):
s3 += chr( ord(c1) ^ ord(c2) )
>>> s3
'\x04\x04\x04'
``` |
13,768,118 | I'm building a python app using the UPS Shipping API. On sending the request (see below) I keep getting the following error:
```
UPS Error 9370701: Invalid processing option.
```
I'm not sure what this means and there isn't much more info in the API documentation. Could someone help me figure out what's going wrong... | 2012/12/07 | [
"https://Stackoverflow.com/questions/13768118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1365008/"
] | Try this
```
DirectoryInfo dir = new DirectoryInfo(Path.GetFullPath(fp));
lb_Files.Items.Clear();
foreach (FileInfo file in dir.GetFiles())
{
lb_Files.Items.Add(new RadListBoxItem(file.ToString(), file.ToString()));
}
``` | No you cannot cast a `String` object into a `RadListBoxItem`, you must create a `RadListBoxItem` using that string as your Value and Text properties:
So replace this:
```
RadListBoxItem rlb = new RadListBoxItem();
rlb = (RadListBoxItem)file.ToString();
//radListBox
lb_Files.Items.Add(rlb.ToString());
```
With t... |
2,100,233 | I have a javascript which takes two variables i.e two lists one is a list of numbers and the other list of strings from django/python
```
numbersvar = [0,1,2,3]
stringsvar = ['a','b','c']
```
The numbersvar is rendered perfectly but when I do {{stringsvar}} it does not render it. | 2010/01/20 | [
"https://Stackoverflow.com/questions/2100233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/228741/"
] | Maybe it will be better to use a **[json](http://www.google.com/url?sa=t&source=web&ct=res&cd=1&ved=0CDkQFjAA&url=http%3A%2F%2Fdocs.python.org%2Flibrary%2Fjson.html&ei=b9pWS7mmO8eK_Abcppz-Aw&usg=AFQjCNG7_WS8ga_dF7-eGjquJarNhC5Eew&sig2=_SZrRNdbAGmbGuW9tVYgHw)** module to create a javascript lists?
```
>>> a = ['stste',... | What does stringsvar contain? The list, or the string representation of the list?
I suggest you pass the correct javascript string representation of the list from the view method to the template to render. Python and javascript array literals have the same syntax, so you could do:
```
def my_view(request):
return... |
10,393,385 | >
> **Possible Duplicate:**
>
> [Instance variables vs. class variables in Python](https://stackoverflow.com/questions/2714573/instance-variables-vs-class-variables-in-python)
>
>
>
What is the difference between these two situations and how is it treated with in Python?
Ex1
```
class MyClass:
anArray =... | 2012/05/01 | [
"https://Stackoverflow.com/questions/10393385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751467/"
] | In the first example, `anArray` (which in Python is called a dictionary, not an array) is a class attribute. It can be accessed using `MyClass.anArray`. It exists as soon as the class is defined.
In the second example, `anArray` is an instance attribute. It can be accessed using `MyClass().anArray`. (But note that do... | It is declared diffrent area.
Ex1 is Like global or static variable.
```
obj = MyClass()
obj2 = MyClass()
print "IS one instance ", id(obj.anArray) == id(obj2.anArray)
```
Ex2 is local attribute.
```
obj = MyClass()
obj2 = MyClass()
print "IS one instance ", id(obj.anArray) == id(obj2.anArray)
``` |
46,374,747 | it's kind of very daunting now. I've tried all I could possibly figure out, to no avail.
I am using ElementaryOS Loki, based on Ubuntu 16.04 LTS.
I have `boost 1.65.1` installed under `/usr/local`
I am using `cmake 3.9.3` which is supporting building boost 1.65.0 and forward.
I have tried every possible way to mess... | 2017/09/23 | [
"https://Stackoverflow.com/questions/46374747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4436572/"
] | Thanks @JohnZwinck for pointing out the obvious over-looked error I had and @James for sharing his answer. but it seems his answer is for Boost 1.63.0, so I wanted to post a solution here so anyone who's having problem with latest CMAKE and Boost Python (up to today) can save some head scratching time.
some prep work ... | There are some dependencies for both CMake and Boost, so I am removing my old answer and providing a link to the bash script on GitHubGist.
The script can be found [here](https://gist.github.com/JamesKBowler/24228a401230c0279d9d966a18abc9e6)
To run the script first make it executable
```
chmod +x boost_python3_insta... |
32,462,512 | I'm trying to create a simple markdown to latex converter, just to learn python and basic regex, but I'm stuck trying to figure out why the below code doesn't work:
```
re.sub (r'\[\*\](.*?)\[\*\]: ?(.*?)$', r'\\footnote{\2}\1', s, flags=re.MULTILINE|re.DOTALL)
```
I want to convert something like:
```
s = """This... | 2015/09/08 | [
"https://Stackoverflow.com/questions/32462512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4699624/"
] | Just lost a week trying to find a suitable tool for Neo4J. It has somehow gotten more difficult. My experience updated from the last post here (2015):
Gephi:
2015: Supported Neo4j
2017: Doesn't support Neo4j
Linxurious:
2015: Free
2017: Discontinued and doesn't list the price
Neoclipse:
2017: No updates since 2014. ... | There are at least 3 GUI tools for neo4j that allow editing:
* [neoclipse](https://github.com/neo4j-contrib/neoclipse/wiki)
* [Gephi](http://gephi.github.io/)
* [linkurious](http://linkurio.us/)
`neoclipse` and `Gephi` are open source and free. `linkurous` has a free open-source community edition. |
32,462,512 | I'm trying to create a simple markdown to latex converter, just to learn python and basic regex, but I'm stuck trying to figure out why the below code doesn't work:
```
re.sub (r'\[\*\](.*?)\[\*\]: ?(.*?)$', r'\\footnote{\2}\1', s, flags=re.MULTILINE|re.DOTALL)
```
I want to convert something like:
```
s = """This... | 2015/09/08 | [
"https://Stackoverflow.com/questions/32462512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4699624/"
] | @Zuriar
Two years after your original post :) but nevertheless ..
Now there is also Graphileon InterActor (<http://www.graphileon.com>) , an enhanced user-interface for Neo4j. Multi-panel, create / update nodes and relations without writing a single line of code.
**UPDATE August 15th, 2018**
We have replaced the Sa... | There are at least 3 GUI tools for neo4j that allow editing:
* [neoclipse](https://github.com/neo4j-contrib/neoclipse/wiki)
* [Gephi](http://gephi.github.io/)
* [linkurious](http://linkurio.us/)
`neoclipse` and `Gephi` are open source and free. `linkurous` has a free open-source community edition. |
32,462,512 | I'm trying to create a simple markdown to latex converter, just to learn python and basic regex, but I'm stuck trying to figure out why the below code doesn't work:
```
re.sub (r'\[\*\](.*?)\[\*\]: ?(.*?)$', r'\\footnote{\2}\1', s, flags=re.MULTILINE|re.DOTALL)
```
I want to convert something like:
```
s = """This... | 2015/09/08 | [
"https://Stackoverflow.com/questions/32462512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4699624/"
] | There are at least 3 GUI tools for neo4j that allow editing:
* [neoclipse](https://github.com/neo4j-contrib/neoclipse/wiki)
* [Gephi](http://gephi.github.io/)
* [linkurious](http://linkurio.us/)
`neoclipse` and `Gephi` are open source and free. `linkurous` has a free open-source community edition. | It seems that Neo4j's new bloom product would be suitable.
neo4j.com/bloom |
32,462,512 | I'm trying to create a simple markdown to latex converter, just to learn python and basic regex, but I'm stuck trying to figure out why the below code doesn't work:
```
re.sub (r'\[\*\](.*?)\[\*\]: ?(.*?)$', r'\\footnote{\2}\1', s, flags=re.MULTILINE|re.DOTALL)
```
I want to convert something like:
```
s = """This... | 2015/09/08 | [
"https://Stackoverflow.com/questions/32462512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4699624/"
] | @Zuriar
Two years after your original post :) but nevertheless ..
Now there is also Graphileon InterActor (<http://www.graphileon.com>) , an enhanced user-interface for Neo4j. Multi-panel, create / update nodes and relations without writing a single line of code.
**UPDATE August 15th, 2018**
We have replaced the Sa... | Just lost a week trying to find a suitable tool for Neo4J. It has somehow gotten more difficult. My experience updated from the last post here (2015):
Gephi:
2015: Supported Neo4j
2017: Doesn't support Neo4j
Linxurious:
2015: Free
2017: Discontinued and doesn't list the price
Neoclipse:
2017: No updates since 2014. ... |
32,462,512 | I'm trying to create a simple markdown to latex converter, just to learn python and basic regex, but I'm stuck trying to figure out why the below code doesn't work:
```
re.sub (r'\[\*\](.*?)\[\*\]: ?(.*?)$', r'\\footnote{\2}\1', s, flags=re.MULTILINE|re.DOTALL)
```
I want to convert something like:
```
s = """This... | 2015/09/08 | [
"https://Stackoverflow.com/questions/32462512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4699624/"
] | Just lost a week trying to find a suitable tool for Neo4J. It has somehow gotten more difficult. My experience updated from the last post here (2015):
Gephi:
2015: Supported Neo4j
2017: Doesn't support Neo4j
Linxurious:
2015: Free
2017: Discontinued and doesn't list the price
Neoclipse:
2017: No updates since 2014. ... | It seems that Neo4j's new bloom product would be suitable.
neo4j.com/bloom |
32,462,512 | I'm trying to create a simple markdown to latex converter, just to learn python and basic regex, but I'm stuck trying to figure out why the below code doesn't work:
```
re.sub (r'\[\*\](.*?)\[\*\]: ?(.*?)$', r'\\footnote{\2}\1', s, flags=re.MULTILINE|re.DOTALL)
```
I want to convert something like:
```
s = """This... | 2015/09/08 | [
"https://Stackoverflow.com/questions/32462512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4699624/"
] | @Zuriar
Two years after your original post :) but nevertheless ..
Now there is also Graphileon InterActor (<http://www.graphileon.com>) , an enhanced user-interface for Neo4j. Multi-panel, create / update nodes and relations without writing a single line of code.
**UPDATE August 15th, 2018**
We have replaced the Sa... | It seems that Neo4j's new bloom product would be suitable.
neo4j.com/bloom |
63,756,753 | I need to be able to run python code on each "node" of the network so that I can test out the code properly. I can't use different port numbers and run the code since I need to handle various other things which kind of force using unique IP addresses. | 2020/09/05 | [
"https://Stackoverflow.com/questions/63756753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6740018/"
] | In my DHT p2p project, I have a specific object that abstract the network communication. During testing I mock that object with an object that operate in memory:
```
class MockProtocol:
def __init__(self, network, peer):
self.network = network
self.peer = peer
async def rpc(self, address, nam... | I think vmware or virtual box can help you. |
62,813,690 | I am writing a script which will poll Jenkins plugin API to fetch a list of plugin dependencies. For this I have used `requests` module of python. It keeps returning empty response, whereas I am getting a JSON response in Postman.
```
import requests
def get_deps():
url = "https://plugins.jenkins.io/api/plugin/CF... | 2020/07/09 | [
"https://Stackoverflow.com/questions/62813690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5649739/"
] | what do you think abous this code : First i calculate the hash and send to server A for signature
```
PdfReader reader = new PdfReader(SRC);
FileOutputStream os = new FileOutputStream(TEMP);
PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0');
PdfSignatureAppearance appearance = stamper.g... | Your `signDocument` method apparently does not accept a pre-calculated hash value but seems to calculate the hash of the data you give it, in your case the (lower case) hex presentation of the hash value you already calculated.
In your first example document you have these values (all hashes are SHA256 hashes):
* Has... |
60,468,634 | I'm fairly new to python and am doing some basic code. I need to know if i can repeat my iteration if the answer is not yes or no. Here is the code (sorry to those of you that think that im doing bad habits). I need the iteration to repeat during else. (The function just outputs text at the moment)
```
if remove_c... | 2020/02/29 | [
"https://Stackoverflow.com/questions/60468634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12985589/"
] | Just put the code into a loop:
```
while True:
if remove_char1_attr1 = 'yes':
char1_attr1.remove(min(char1_attr1))
char1_attr1_5 = random.randint(1,6)
char1_attr1.append(char1_attr1_5)
print("The numbers are now as follows: " +char1_attr1 )
elif remove_char1_attr1 = 'no'
... | You can try looping while it's not yes or no
```py
while remove_char1_attr1 not in ('yes', 'no'):
if remove_char1_attr1 = 'yes':
char1_attr1.remove(min(char1_attr1))
char1_attr1_5 = random.randint(1,6)
char1_attr1.append(char1_attr1_5)
print("The numbers are now as follows: " +c... |
52,415,096 | I am calling a new object to manage an Azure Resource and using the Azure python packages. While calling it, i get a maximum depth exceeded error however if I step through the code in a python shell I don't get this issue. Below is the **init** method
```
class WindowsDeployer(object):
def __init__(self, params):
... | 2018/09/19 | [
"https://Stackoverflow.com/questions/52415096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6781059/"
] | Thanks for the help above. The issue was with my gevent packages (not sure exactly what) however adding upgrading gevent and adding the following lines fixed it.
```
import gevent.monkey
gevent.monkey.patch_all()
``` | I had a similar problem when using the `azure-storage-blob` module, and adding the following lines fixed it. I do not know why. It makes me confused.
Exception:
>
> maximum recursion depth exceeded while calling a Python object
>
>
>
Solution:
```
import gevent.monkey
gevent.monkey.patch_all()
``` |
72,921,087 | Taking this command to start local server for example, the command includes -m, what is the meaning of -m in genearl?
```
python3 -m http.server
``` | 2022/07/09 | [
"https://Stackoverflow.com/questions/72921087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4877535/"
] | From the documentation, which can be invoked using `python3 --help`.
```
-m mod : run library module as a script (terminates option list)
```
Instead of importing the module in another script (like `import <module-name>`), you directly run it as a script. | The -m stands for module-name in Python. |
27,793,025 | I can't use Java and Python at the same time.
When I set
```
%JAVAHOME%\bin; %PYTHONPATH%;
```
I can use java, but not python. When I set
```
%PYTHONPATH%; %JAVAHOME%\bin;
```
I can use python, but not java.
I'm using windows 7. How can I go about fixing this problem? | 2015/01/06 | [
"https://Stackoverflow.com/questions/27793025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4422583/"
] | Don't put a space in your `PATH` entries
```
set "PATH=%JAVAHOME%\bin;%PYTHONPATH%;%PATH%"
``` | 1. Select Start, select Control Panel. double click System, and select the Advanced tab.
2. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. ...
3. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variab... |
27,793,025 | I can't use Java and Python at the same time.
When I set
```
%JAVAHOME%\bin; %PYTHONPATH%;
```
I can use java, but not python. When I set
```
%PYTHONPATH%; %JAVAHOME%\bin;
```
I can use python, but not java.
I'm using windows 7. How can I go about fixing this problem? | 2015/01/06 | [
"https://Stackoverflow.com/questions/27793025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4422583/"
] | Don't put a space in your `PATH` entries
```
set "PATH=%JAVAHOME%\bin;%PYTHONPATH%;%PATH%"
``` | Have you tried removing the space after the semicolon
```
%JAVAHOME%\bin;%PYTHONPATH%;
``` |
27,793,025 | I can't use Java and Python at the same time.
When I set
```
%JAVAHOME%\bin; %PYTHONPATH%;
```
I can use java, but not python. When I set
```
%PYTHONPATH%; %JAVAHOME%\bin;
```
I can use python, but not java.
I'm using windows 7. How can I go about fixing this problem? | 2015/01/06 | [
"https://Stackoverflow.com/questions/27793025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4422583/"
] | Don't put a space in your `PATH` entries
```
set "PATH=%JAVAHOME%\bin;%PYTHONPATH%;%PATH%"
``` | ```
Select Start, select Control Panel. double click System, and select the Advanced tab.
Click Environment Variables. In the section System Variables or User Variable, find
the PATH environment variable and edit it.and write the path of your compiler like this way:
Assume that your
java compiler path is:D:\java\bin
... |
40,652,793 | I run a bash script with which start a python script to run in background
```
#!/bin/bash
python test.py &
```
So how i can i kill the script with bash script also?
I used the following command to kill but output `no process found`
```
killall $(ps aux | grep test.py | grep -v grep | awk '{ print $1 }')
```
I t... | 2016/11/17 | [
"https://Stackoverflow.com/questions/40652793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6180818/"
] | Use `pkill` command as
```
pkill -f test.py
```
(or) a more fool-proof way using `pgrep` to search for the actual process-id
```
kill $(pgrep -f 'python test.py')
```
Or if more than one instance of the running program is identified and all of them needs to be killed, use [killall(1)](https://linux.die.net/man/1/... | You can use the `!` to get the PID of the last command.
I would suggest something similar to the following, that also check if the process you want to run is already running:
```
#!/bin/bash
if [[ ! -e /tmp/test.py.pid ]]; then # Check if the file already exists
python test.py & #+and if so d... |
40,652,793 | I run a bash script with which start a python script to run in background
```
#!/bin/bash
python test.py &
```
So how i can i kill the script with bash script also?
I used the following command to kill but output `no process found`
```
killall $(ps aux | grep test.py | grep -v grep | awk '{ print $1 }')
```
I t... | 2016/11/17 | [
"https://Stackoverflow.com/questions/40652793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6180818/"
] | Use `pkill` command as
```
pkill -f test.py
```
(or) a more fool-proof way using `pgrep` to search for the actual process-id
```
kill $(pgrep -f 'python test.py')
```
Or if more than one instance of the running program is identified and all of them needs to be killed, use [killall(1)](https://linux.die.net/man/1/... | ```
ps -ef | grep python
```
it will return the "pid" then kill the process by
```
sudo kill -9 pid
```
eg output of ps command:
user 13035 4729 0 13:44 pts/10 00:00:00 python (here 13035 is pid) |
40,652,793 | I run a bash script with which start a python script to run in background
```
#!/bin/bash
python test.py &
```
So how i can i kill the script with bash script also?
I used the following command to kill but output `no process found`
```
killall $(ps aux | grep test.py | grep -v grep | awk '{ print $1 }')
```
I t... | 2016/11/17 | [
"https://Stackoverflow.com/questions/40652793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6180818/"
] | Use `pkill` command as
```
pkill -f test.py
```
(or) a more fool-proof way using `pgrep` to search for the actual process-id
```
kill $(pgrep -f 'python test.py')
```
Or if more than one instance of the running program is identified and all of them needs to be killed, use [killall(1)](https://linux.die.net/man/1/... | With the use of bashisms.
```
#!/bin/bash
python test.py &
kill $!
```
`$!` is the PID of the last process started in background. You can also save it in another variable if you start multiple scripts in the background. |
40,652,793 | I run a bash script with which start a python script to run in background
```
#!/bin/bash
python test.py &
```
So how i can i kill the script with bash script also?
I used the following command to kill but output `no process found`
```
killall $(ps aux | grep test.py | grep -v grep | awk '{ print $1 }')
```
I t... | 2016/11/17 | [
"https://Stackoverflow.com/questions/40652793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6180818/"
] | Use `pkill` command as
```
pkill -f test.py
```
(or) a more fool-proof way using `pgrep` to search for the actual process-id
```
kill $(pgrep -f 'python test.py')
```
Or if more than one instance of the running program is identified and all of them needs to be killed, use [killall(1)](https://linux.die.net/man/1/... | ```
killall python3
```
will interrupt ***any and all*** python3 scripts running. |
40,652,793 | I run a bash script with which start a python script to run in background
```
#!/bin/bash
python test.py &
```
So how i can i kill the script with bash script also?
I used the following command to kill but output `no process found`
```
killall $(ps aux | grep test.py | grep -v grep | awk '{ print $1 }')
```
I t... | 2016/11/17 | [
"https://Stackoverflow.com/questions/40652793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6180818/"
] | You can use the `!` to get the PID of the last command.
I would suggest something similar to the following, that also check if the process you want to run is already running:
```
#!/bin/bash
if [[ ! -e /tmp/test.py.pid ]]; then # Check if the file already exists
python test.py & #+and if so d... | ```
ps -ef | grep python
```
it will return the "pid" then kill the process by
```
sudo kill -9 pid
```
eg output of ps command:
user 13035 4729 0 13:44 pts/10 00:00:00 python (here 13035 is pid) |
40,652,793 | I run a bash script with which start a python script to run in background
```
#!/bin/bash
python test.py &
```
So how i can i kill the script with bash script also?
I used the following command to kill but output `no process found`
```
killall $(ps aux | grep test.py | grep -v grep | awk '{ print $1 }')
```
I t... | 2016/11/17 | [
"https://Stackoverflow.com/questions/40652793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6180818/"
] | You can use the `!` to get the PID of the last command.
I would suggest something similar to the following, that also check if the process you want to run is already running:
```
#!/bin/bash
if [[ ! -e /tmp/test.py.pid ]]; then # Check if the file already exists
python test.py & #+and if so d... | With the use of bashisms.
```
#!/bin/bash
python test.py &
kill $!
```
`$!` is the PID of the last process started in background. You can also save it in another variable if you start multiple scripts in the background. |
40,652,793 | I run a bash script with which start a python script to run in background
```
#!/bin/bash
python test.py &
```
So how i can i kill the script with bash script also?
I used the following command to kill but output `no process found`
```
killall $(ps aux | grep test.py | grep -v grep | awk '{ print $1 }')
```
I t... | 2016/11/17 | [
"https://Stackoverflow.com/questions/40652793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6180818/"
] | You can use the `!` to get the PID of the last command.
I would suggest something similar to the following, that also check if the process you want to run is already running:
```
#!/bin/bash
if [[ ! -e /tmp/test.py.pid ]]; then # Check if the file already exists
python test.py & #+and if so d... | ```
killall python3
```
will interrupt ***any and all*** python3 scripts running. |
25,065,017 | I'm learning objective c a little bit to write an iPad app. I've mostly done some html5/php projects and learned some python at university. But one thing that really blows my mind is how hard it is to just style some text in an objective C label.
Maybe I'm coming from a lazy markdown generation, but really, if I want ... | 2014/07/31 | [
"https://Stackoverflow.com/questions/25065017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2517546/"
] | You can use `NSAttributedString`'s `data:options:documentAttributes:error:` initializer (first available in iOS 7.0 SDK).
```
import UIKit
let htmlString = "<b>Objective</b>: Construct an <i>equilateral</i> triangle from the line segment AB."
let htmlData = htmlString.dataUsingEncoding(NSUTF8StringEncoding)
let opti... | I faced similar frustrations while trying to use attributed text in Xcode, so I feel your pain. You can definitely use multiple `NSMutableAttributedtext`'s to get the job done, but this is very rigid.
```
UIFont *normalFont = [UIFont fontWithName:@"..." size:20];
UIFont *boldFont = [UIFont fontWithName:@"..." size:20]... |
25,065,017 | I'm learning objective c a little bit to write an iPad app. I've mostly done some html5/php projects and learned some python at university. But one thing that really blows my mind is how hard it is to just style some text in an objective C label.
Maybe I'm coming from a lazy markdown generation, but really, if I want ... | 2014/07/31 | [
"https://Stackoverflow.com/questions/25065017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2517546/"
] | I faced similar frustrations while trying to use attributed text in Xcode, so I feel your pain. You can definitely use multiple `NSMutableAttributedtext`'s to get the job done, but this is very rigid.
```
UIFont *normalFont = [UIFont fontWithName:@"..." size:20];
UIFont *boldFont = [UIFont fontWithName:@"..." size:20]... | Just to update the [akashivskyy’s answer](https://stackoverflow.com/a/25068643/1271826) (+1) with contemporary Swift syntax:
```swift
guard let data = htmlString.data(using: .utf8) else { return }
do {
let attributedString = try NSAttributedString(
data: data,
options: [.documentType: NSAttributed... |
25,065,017 | I'm learning objective c a little bit to write an iPad app. I've mostly done some html5/php projects and learned some python at university. But one thing that really blows my mind is how hard it is to just style some text in an objective C label.
Maybe I'm coming from a lazy markdown generation, but really, if I want ... | 2014/07/31 | [
"https://Stackoverflow.com/questions/25065017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2517546/"
] | You can use `NSAttributedString`'s `data:options:documentAttributes:error:` initializer (first available in iOS 7.0 SDK).
```
import UIKit
let htmlString = "<b>Objective</b>: Construct an <i>equilateral</i> triangle from the line segment AB."
let htmlData = htmlString.dataUsingEncoding(NSUTF8StringEncoding)
let opti... | Just to update the [akashivskyy’s answer](https://stackoverflow.com/a/25068643/1271826) (+1) with contemporary Swift syntax:
```swift
guard let data = htmlString.data(using: .utf8) else { return }
do {
let attributedString = try NSAttributedString(
data: data,
options: [.documentType: NSAttributed... |
22,071,987 | I haven't been able to find a function to generate an array of random floats of a given length between a certain range.
I've looked at [Random sampling](http://docs.scipy.org/doc/numpy/reference/routines.random.html) but no function seems to do what I need.
[random.uniform](http://docs.python.org/2/library/random.htm... | 2014/02/27 | [
"https://Stackoverflow.com/questions/22071987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1391441/"
] | [`np.random.uniform`](https://numpy.org/doc/stable/reference/random/generated/numpy.random.uniform.html) fits your use case:
```
sampl = np.random.uniform(low=0.5, high=13.3, size=(50,))
```
**Update Oct 2019:**
While the syntax is still supported, it looks like the API changed with NumPy 1.17 to support greater co... | This is the simplest way
```
np.random.uniform(start,stop,(rows,columns))
``` |
22,071,987 | I haven't been able to find a function to generate an array of random floats of a given length between a certain range.
I've looked at [Random sampling](http://docs.scipy.org/doc/numpy/reference/routines.random.html) but no function seems to do what I need.
[random.uniform](http://docs.python.org/2/library/random.htm... | 2014/02/27 | [
"https://Stackoverflow.com/questions/22071987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1391441/"
] | Why not use a list comprehension?
In Python 2
```
ran_floats = [random.uniform(low,high) for _ in xrange(size)]
```
In Python 3, `range` works like `xrange`([ref](https://www.geeksforgeeks.org/range-vs-xrange-python/))
```
ran_floats = [random.uniform(low,high) for _ in range(size)]
``` | The for loop in list comprehension takes time and makes it slow.
It is better to use numpy parameters (low, high, size, ..etc)
```
import numpy as np
import time
rang = 10000
tic = time.time()
for i in range(rang):
sampl = np.random.uniform(low=0, high=2, size=(182))
print("it took: ", time.time() - tic)
tic = ti... |
22,071,987 | I haven't been able to find a function to generate an array of random floats of a given length between a certain range.
I've looked at [Random sampling](http://docs.scipy.org/doc/numpy/reference/routines.random.html) but no function seems to do what I need.
[random.uniform](http://docs.python.org/2/library/random.htm... | 2014/02/27 | [
"https://Stackoverflow.com/questions/22071987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1391441/"
] | There may already be a function to do what you're looking for, but I don't know about it (yet?).
In the meantime, I would suggess using:
```
ran_floats = numpy.random.rand(50) * (13.3-0.5) + 0.5
```
This will produce an array of shape (50,) with a uniform distribution between 0.5 and 13.3.
You could also define a f... | The for loop in list comprehension takes time and makes it slow.
It is better to use numpy parameters (low, high, size, ..etc)
```
import numpy as np
import time
rang = 10000
tic = time.time()
for i in range(rang):
sampl = np.random.uniform(low=0, high=2, size=(182))
print("it took: ", time.time() - tic)
tic = ti... |
22,071,987 | I haven't been able to find a function to generate an array of random floats of a given length between a certain range.
I've looked at [Random sampling](http://docs.scipy.org/doc/numpy/reference/routines.random.html) but no function seems to do what I need.
[random.uniform](http://docs.python.org/2/library/random.htm... | 2014/02/27 | [
"https://Stackoverflow.com/questions/22071987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1391441/"
] | Why not to combine [random.uniform](http://docs.python.org/2/library/random.html#random.uniform) with a list comprehension?
```
>>> def random_floats(low, high, size):
... return [random.uniform(low, high) for _ in xrange(size)]
...
>>> random_floats(0.5, 2.8, 5)
[2.366910411506704, 1.878800401620107, 1.0145196974... | This should work for your example
```
sample = (np.random.random([50, ]) * 13.3) - 0.5
``` |
22,071,987 | I haven't been able to find a function to generate an array of random floats of a given length between a certain range.
I've looked at [Random sampling](http://docs.scipy.org/doc/numpy/reference/routines.random.html) but no function seems to do what I need.
[random.uniform](http://docs.python.org/2/library/random.htm... | 2014/02/27 | [
"https://Stackoverflow.com/questions/22071987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1391441/"
] | [`np.random.uniform`](https://numpy.org/doc/stable/reference/random/generated/numpy.random.uniform.html) fits your use case:
```
sampl = np.random.uniform(low=0.5, high=13.3, size=(50,))
```
**Update Oct 2019:**
While the syntax is still supported, it looks like the API changed with NumPy 1.17 to support greater co... | `np.random.random_sample(size)` will generate random floats in the half-open interval [0.0, 1.0). |
22,071,987 | I haven't been able to find a function to generate an array of random floats of a given length between a certain range.
I've looked at [Random sampling](http://docs.scipy.org/doc/numpy/reference/routines.random.html) but no function seems to do what I need.
[random.uniform](http://docs.python.org/2/library/random.htm... | 2014/02/27 | [
"https://Stackoverflow.com/questions/22071987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1391441/"
] | Alternatively you could use [SciPy](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.uniform.html)
```
from scipy import stats
stats.uniform(0.5, 13.3).rvs(50)
```
and for the record to sample integers it's
```
stats.randint(10, 20).rvs(50)
``` | The for loop in list comprehension takes time and makes it slow.
It is better to use numpy parameters (low, high, size, ..etc)
```
import numpy as np
import time
rang = 10000
tic = time.time()
for i in range(rang):
sampl = np.random.uniform(low=0, high=2, size=(182))
print("it took: ", time.time() - tic)
tic = ti... |
22,071,987 | I haven't been able to find a function to generate an array of random floats of a given length between a certain range.
I've looked at [Random sampling](http://docs.scipy.org/doc/numpy/reference/routines.random.html) but no function seems to do what I need.
[random.uniform](http://docs.python.org/2/library/random.htm... | 2014/02/27 | [
"https://Stackoverflow.com/questions/22071987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1391441/"
] | The for loop in list comprehension takes time and makes it slow.
It is better to use numpy parameters (low, high, size, ..etc)
```
import numpy as np
import time
rang = 10000
tic = time.time()
for i in range(rang):
sampl = np.random.uniform(low=0, high=2, size=(182))
print("it took: ", time.time() - tic)
tic = ti... | This should work for your example
```
sample = (np.random.random([50, ]) * 13.3) - 0.5
``` |
22,071,987 | I haven't been able to find a function to generate an array of random floats of a given length between a certain range.
I've looked at [Random sampling](http://docs.scipy.org/doc/numpy/reference/routines.random.html) but no function seems to do what I need.
[random.uniform](http://docs.python.org/2/library/random.htm... | 2014/02/27 | [
"https://Stackoverflow.com/questions/22071987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1391441/"
] | Why not use a list comprehension?
In Python 2
```
ran_floats = [random.uniform(low,high) for _ in xrange(size)]
```
In Python 3, `range` works like `xrange`([ref](https://www.geeksforgeeks.org/range-vs-xrange-python/))
```
ran_floats = [random.uniform(low,high) for _ in range(size)]
``` | This should work for your example
```
sample = (np.random.random([50, ]) * 13.3) - 0.5
``` |
22,071,987 | I haven't been able to find a function to generate an array of random floats of a given length between a certain range.
I've looked at [Random sampling](http://docs.scipy.org/doc/numpy/reference/routines.random.html) but no function seems to do what I need.
[random.uniform](http://docs.python.org/2/library/random.htm... | 2014/02/27 | [
"https://Stackoverflow.com/questions/22071987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1391441/"
] | Why not use a list comprehension?
In Python 2
```
ran_floats = [random.uniform(low,high) for _ in xrange(size)]
```
In Python 3, `range` works like `xrange`([ref](https://www.geeksforgeeks.org/range-vs-xrange-python/))
```
ran_floats = [random.uniform(low,high) for _ in range(size)]
``` | This is the simplest way
```
np.random.uniform(start,stop,(rows,columns))
``` |
22,071,987 | I haven't been able to find a function to generate an array of random floats of a given length between a certain range.
I've looked at [Random sampling](http://docs.scipy.org/doc/numpy/reference/routines.random.html) but no function seems to do what I need.
[random.uniform](http://docs.python.org/2/library/random.htm... | 2014/02/27 | [
"https://Stackoverflow.com/questions/22071987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1391441/"
] | This is the simplest way
```
np.random.uniform(start,stop,(rows,columns))
``` | The for loop in list comprehension takes time and makes it slow.
It is better to use numpy parameters (low, high, size, ..etc)
```
import numpy as np
import time
rang = 10000
tic = time.time()
for i in range(rang):
sampl = np.random.uniform(low=0, high=2, size=(182))
print("it took: ", time.time() - tic)
tic = ti... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.