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
51,113,531
I am setting up `docker-for-windows` on my private pc. When I set it up a while ago on my office laptop I had the same issue but it just stopped happening. So I am stuck with this: I have a docker-working project (on my other computer) with a `docker-compose.yml` like this: ``` version: '2' services: web: de...
2018/06/30
[ "https://Stackoverflow.com/questions/51113531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1331671/" ]
If possible can you please provide all the files related to this, so that i can try to reproduce the issue. Seems like command is not executing is the dir where run\_web\_local.sh exist. You can check the current workdir by replacing command in docker-compose.yml as `command: pwd && bash ./run_web_local.sh`
Do not use -d at the end. Instead of this command **docker-compose -f start\_tools.yaml up –d** Use **docker-compose -f start\_tools.yaml up**
51,113,531
I am setting up `docker-for-windows` on my private pc. When I set it up a while ago on my office laptop I had the same issue but it just stopped happening. So I am stuck with this: I have a docker-working project (on my other computer) with a `docker-compose.yml` like this: ``` version: '2' services: web: de...
2018/06/30
[ "https://Stackoverflow.com/questions/51113531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1331671/" ]
It may be because the bash file is not in the root path or in the root path of workdir. Check where is it in the container and verify if the path is correct.
Do not use -d at the end. Instead of this command **docker-compose -f start\_tools.yaml up –d** Use **docker-compose -f start\_tools.yaml up**
51,113,531
I am setting up `docker-for-windows` on my private pc. When I set it up a while ago on my office laptop I had the same issue but it just stopped happening. So I am stuck with this: I have a docker-working project (on my other computer) with a `docker-compose.yml` like this: ``` version: '2' services: web: de...
2018/06/30
[ "https://Stackoverflow.com/questions/51113531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1331671/" ]
I had same issue recently and the problems goes away using any advanced editor and changing line ending to unix style on sh entrypoint scripts. In my case, not sure why, because git handle it very well depending on linux or windows host I ended up in same situation. If you have files mounted in container and host(in w...
It may be because the bash file is not in the root path or in the root path of workdir. Check where is it in the container and verify if the path is correct.
51,113,531
I am setting up `docker-for-windows` on my private pc. When I set it up a while ago on my office laptop I had the same issue but it just stopped happening. So I am stuck with this: I have a docker-working project (on my other computer) with a `docker-compose.yml` like this: ``` version: '2' services: web: de...
2018/06/30
[ "https://Stackoverflow.com/questions/51113531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1331671/" ]
I had same issue recently and the problems goes away using any advanced editor and changing line ending to unix style on sh entrypoint scripts. In my case, not sure why, because git handle it very well depending on linux or windows host I ended up in same situation. If you have files mounted in container and host(in w...
If possible can you please provide all the files related to this, so that i can try to reproduce the issue. Seems like command is not executing is the dir where run\_web\_local.sh exist. You can check the current workdir by replacing command in docker-compose.yml as `command: pwd && bash ./run_web_local.sh`
63,694,387
The below is a selenium python code where I am trying to click Sign In by sending the login details via selenium. However, when I am using `find_element_by_id` method to locate the username and password input area the scripts throws an error `Message: no such element: Unable to locate element: {"method":"css selector",...
2020/09/01
[ "https://Stackoverflow.com/questions/63694387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8599554/" ]
don't initialized the variables. use the `nillable` attribute and set it value to `true` ``` @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "currencyCode", "discountValue", "setPrice" }) @XmlRootElement(name = "countryData") public class CountryData { @XmlElement(nillable=true) protect...
Although the strings are empty they still contain non-null data and the end tag is generated. Remove the default values of the strings or set them as `null` (a default instance field value): ``` protected String discountValue; protected String setPrice; ``` The tags become closed: ``` <discountValue/> <setPrice/> ...
1,736,655
Before resorting to stackoverflow, i have spend a lot of times looking for the solutions. I have been a linux-user/developer for few years, now shifting to windows-7. I am looking for seting-up a development environment (mainly c/c++/bash/python) on my windows machine. Solutions i tired - * VirtuaBox latest, with ...
2009/11/15
[ "https://Stackoverflow.com/questions/1736655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132597/" ]
Here is what I do for Python development on Windows: * EasyEclipse for Python (includes eclipse, subclipse, pydev) * GNU Win32 [Native Windows ports for GNU tools](http://gnuwin32.sourceforge.net/) * Vim and Emacs (for non-IDE editing work)
The following suggestions hold if you are not going to do complex template programming as the c++ IDE's other than visual studio SUCK, they cannot efficiently index modern C++ code (the boost library). I would suggest using Netbeans (it has far better support for C++ than eclipse/CDT) with the following two build envi...
1,736,655
Before resorting to stackoverflow, i have spend a lot of times looking for the solutions. I have been a linux-user/developer for few years, now shifting to windows-7. I am looking for seting-up a development environment (mainly c/c++/bash/python) on my windows machine. Solutions i tired - * VirtuaBox latest, with ...
2009/11/15
[ "https://Stackoverflow.com/questions/1736655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132597/" ]
Here is what I do for Python development on Windows: * EasyEclipse for Python (includes eclipse, subclipse, pydev) * GNU Win32 [Native Windows ports for GNU tools](http://gnuwin32.sourceforge.net/) * Vim and Emacs (for non-IDE editing work)
I would see if MSysGit can provide what you want first. also since man pages aren't really anything hugely impressive... it might just be possible to just copy them. I've had problems with cygwin, although to be honest I'm not happy with MSys, MSysGit, or Cygwin. I wish someone would build one that was more... linux li...
1,736,655
Before resorting to stackoverflow, i have spend a lot of times looking for the solutions. I have been a linux-user/developer for few years, now shifting to windows-7. I am looking for seting-up a development environment (mainly c/c++/bash/python) on my windows machine. Solutions i tired - * VirtuaBox latest, with ...
2009/11/15
[ "https://Stackoverflow.com/questions/1736655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132597/" ]
Here is what I do for Python development on Windows: * EasyEclipse for Python (includes eclipse, subclipse, pydev) * GNU Win32 [Native Windows ports for GNU tools](http://gnuwin32.sourceforge.net/) * Vim and Emacs (for non-IDE editing work)
I would recommend [Bloodshed DevC++](http://www.bloodshed.net/devcpp.html) as a good basic non-microsoft specific Windows solution for developing ANSI C/C++ code. Personally I just use Visual Studio 2008 and ignore all the Microsoft specific extensions. For Python there is the wonderful Komodo Edit software that is fr...
1,736,655
Before resorting to stackoverflow, i have spend a lot of times looking for the solutions. I have been a linux-user/developer for few years, now shifting to windows-7. I am looking for seting-up a development environment (mainly c/c++/bash/python) on my windows machine. Solutions i tired - * VirtuaBox latest, with ...
2009/11/15
[ "https://Stackoverflow.com/questions/1736655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132597/" ]
I recommend VirtualBox+Ubuntu. Cygwin just doesn't cut it for certain tasks and is in beta for Win7.
IMO I'd say VirtualBox + Gentoo Linux + KDevelop4, Gentoo will give you the control you need over your environment. I'm doing exactly the opposite of you, I have gcc/qt4 installed on wine to compile for windows and using Linux primarily.
1,736,655
Before resorting to stackoverflow, i have spend a lot of times looking for the solutions. I have been a linux-user/developer for few years, now shifting to windows-7. I am looking for seting-up a development environment (mainly c/c++/bash/python) on my windows machine. Solutions i tired - * VirtuaBox latest, with ...
2009/11/15
[ "https://Stackoverflow.com/questions/1736655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132597/" ]
Here is what I do for Python development on Windows: * EasyEclipse for Python (includes eclipse, subclipse, pydev) * GNU Win32 [Native Windows ports for GNU tools](http://gnuwin32.sourceforge.net/) * Vim and Emacs (for non-IDE editing work)
If you want to do development of POSIX applications (mostly command line), with all the familiar Linux tools, then cygwin is your best bet. It probably include everything you are used to. But if you will try to do Windows development (anything with UI, drivers, services), then Visual Studio is really gold. And in gen...
1,736,655
Before resorting to stackoverflow, i have spend a lot of times looking for the solutions. I have been a linux-user/developer for few years, now shifting to windows-7. I am looking for seting-up a development environment (mainly c/c++/bash/python) on my windows machine. Solutions i tired - * VirtuaBox latest, with ...
2009/11/15
[ "https://Stackoverflow.com/questions/1736655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132597/" ]
Here is what I do for Python development on Windows: * EasyEclipse for Python (includes eclipse, subclipse, pydev) * GNU Win32 [Native Windows ports for GNU tools](http://gnuwin32.sourceforge.net/) * Vim and Emacs (for non-IDE editing work)
IMO I'd say VirtualBox + Gentoo Linux + KDevelop4, Gentoo will give you the control you need over your environment. I'm doing exactly the opposite of you, I have gcc/qt4 installed on wine to compile for windows and using Linux primarily.
1,736,655
Before resorting to stackoverflow, i have spend a lot of times looking for the solutions. I have been a linux-user/developer for few years, now shifting to windows-7. I am looking for seting-up a development environment (mainly c/c++/bash/python) on my windows machine. Solutions i tired - * VirtuaBox latest, with ...
2009/11/15
[ "https://Stackoverflow.com/questions/1736655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132597/" ]
I recommend VirtualBox+Ubuntu. Cygwin just doesn't cut it for certain tasks and is in beta for Win7.
I would see if MSysGit can provide what you want first. also since man pages aren't really anything hugely impressive... it might just be possible to just copy them. I've had problems with cygwin, although to be honest I'm not happy with MSys, MSysGit, or Cygwin. I wish someone would build one that was more... linux li...
1,736,655
Before resorting to stackoverflow, i have spend a lot of times looking for the solutions. I have been a linux-user/developer for few years, now shifting to windows-7. I am looking for seting-up a development environment (mainly c/c++/bash/python) on my windows machine. Solutions i tired - * VirtuaBox latest, with ...
2009/11/15
[ "https://Stackoverflow.com/questions/1736655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132597/" ]
I recommend VirtualBox+Ubuntu. Cygwin just doesn't cut it for certain tasks and is in beta for Win7.
If you want to do development of POSIX applications (mostly command line), with all the familiar Linux tools, then cygwin is your best bet. It probably include everything you are used to. But if you will try to do Windows development (anything with UI, drivers, services), then Visual Studio is really gold. And in gen...
1,736,655
Before resorting to stackoverflow, i have spend a lot of times looking for the solutions. I have been a linux-user/developer for few years, now shifting to windows-7. I am looking for seting-up a development environment (mainly c/c++/bash/python) on my windows machine. Solutions i tired - * VirtuaBox latest, with ...
2009/11/15
[ "https://Stackoverflow.com/questions/1736655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132597/" ]
I recommend VirtualBox+Ubuntu. Cygwin just doesn't cut it for certain tasks and is in beta for Win7.
Here is what I do for Python development on Windows: * EasyEclipse for Python (includes eclipse, subclipse, pydev) * GNU Win32 [Native Windows ports for GNU tools](http://gnuwin32.sourceforge.net/) * Vim and Emacs (for non-IDE editing work)
1,736,655
Before resorting to stackoverflow, i have spend a lot of times looking for the solutions. I have been a linux-user/developer for few years, now shifting to windows-7. I am looking for seting-up a development environment (mainly c/c++/bash/python) on my windows machine. Solutions i tired - * VirtuaBox latest, with ...
2009/11/15
[ "https://Stackoverflow.com/questions/1736655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132597/" ]
I recommend VirtualBox+Ubuntu. Cygwin just doesn't cut it for certain tasks and is in beta for Win7.
The following suggestions hold if you are not going to do complex template programming as the c++ IDE's other than visual studio SUCK, they cannot efficiently index modern C++ code (the boost library). I would suggest using Netbeans (it has far better support for C++ than eclipse/CDT) with the following two build envi...
16,648,670
I am developing the structure of the MySQL database and I've faced a small decisional problem about its structure. I have 2 tables: 1. All messages published on the site. 2. All comments published on the site. Every message can have more than one comment associated to it. What is a better way to make connection bet...
2013/05/20
[ "https://Stackoverflow.com/questions/16648670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/656100/" ]
The first option is the way to go. So you'll have: comment\_id | message\_id | comment\_text | timestamp etc. For your MySQL table you can specify to build the index over the first two columns for good performance. 10Mio Comments should work OK, but you could test this in advance with a test scenario yourself. If...
Option one is the best approach. You'll want an index on the `message_id` column in the comments table. This allows MySQL to quickly and efficiently pull out all the comments for a particular message, even when there are hundreds of thousands of comments.
71,607,064
In openai.py the Completion.create is highlighting as alert and also not working.. the error is right down below.. whats the problem with the code ``` response = openai.Completion.create( engine="text-davinci-002", prompt="Generate blog topic on: Ethical hacking", temperature=0.7, max_tokens=256, t...
2022/03/24
[ "https://Stackoverflow.com/questions/71607064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16521679/" ]
for my fellow doofuses going thru all the above suggestions and wondering why its not working: make sure your file is NOT named `openai.py`. because then it will call itself, because python. wasted 2 hours on this nonsense lol. relevant link [How to fix AttributeError: partially initialized module?](https://stackove...
Try this, engine="davinci"
71,607,064
In openai.py the Completion.create is highlighting as alert and also not working.. the error is right down below.. whats the problem with the code ``` response = openai.Completion.create( engine="text-davinci-002", prompt="Generate blog topic on: Ethical hacking", temperature=0.7, max_tokens=256, t...
2022/03/24
[ "https://Stackoverflow.com/questions/71607064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16521679/" ]
for my fellow doofuses going thru all the above suggestions and wondering why its not working: make sure your file is NOT named `openai.py`. because then it will call itself, because python. wasted 2 hours on this nonsense lol. relevant link [How to fix AttributeError: partially initialized module?](https://stackove...
I tried the openai version 0.18.1 and was able to run a sample GPT-3 code. ``` pip install openai==0.18.1 import openai import config openai.api_key = config.OPENAI_API_KEY if 'OPENAI_API_KEY' in dir(config) else '' print(f'openai.api_key : {openai.api_key}') def openAIQuery(query): response = openai.Completion...
71,607,064
In openai.py the Completion.create is highlighting as alert and also not working.. the error is right down below.. whats the problem with the code ``` response = openai.Completion.create( engine="text-davinci-002", prompt="Generate blog topic on: Ethical hacking", temperature=0.7, max_tokens=256, t...
2022/03/24
[ "https://Stackoverflow.com/questions/71607064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16521679/" ]
for my fellow doofuses going thru all the above suggestions and wondering why its not working: make sure your file is NOT named `openai.py`. because then it will call itself, because python. wasted 2 hours on this nonsense lol. relevant link [How to fix AttributeError: partially initialized module?](https://stackove...
Upgrade `openai` module or try reinstalling it. `text-davinci-002` is a correct engine name, so no need to change it.
57,449,963
I want to install ansible in RHEL 8 Centos. To use yum install ansible i must enable epel release but i can't find a best source of epel release for Rhel 8. **I tried this** ``` sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm sudo yum install ansible ``` **The output i got ...
2019/08/11
[ "https://Stackoverflow.com/questions/57449963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7179457/" ]
EPEL8 is not released yet. There are some packages available, but a lot are still being worked on and the repo is not considered "generally available". For now, you can install Ansible from the Python Package Index (PyPI): ``` yum install python3-pip pip3 install ansible ```
If you are using RHEL 8 then you can use the subscription manager to get Ansible with the host and config file pre-built. Also, you will need to create an account on <https://developers.redhat.com> before you can do this: ``` subscription-manager register --auto-attach subscription-manager repos --enable ansible-2.8...
57,449,963
I want to install ansible in RHEL 8 Centos. To use yum install ansible i must enable epel release but i can't find a best source of epel release for Rhel 8. **I tried this** ``` sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm sudo yum install ansible ``` **The output i got ...
2019/08/11
[ "https://Stackoverflow.com/questions/57449963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7179457/" ]
EPEL8 is not released yet. There are some packages available, but a lot are still being worked on and the repo is not considered "generally available". For now, you can install Ansible from the Python Package Index (PyPI): ``` yum install python3-pip pip3 install ansible ```
This worked for RHEL9 Should work for RHEL8 as well ``` [root@controller yum.repos.d]# yum list | grep ansible ansible-collection-microsoft-sql.noarch 1.1.1-3.el9_0 Local-AppStream ansible-collection-redhat-rhel_mgmt.noarch 1.0.0-2.el9 Local-AppSt...
57,449,963
I want to install ansible in RHEL 8 Centos. To use yum install ansible i must enable epel release but i can't find a best source of epel release for Rhel 8. **I tried this** ``` sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm sudo yum install ansible ``` **The output i got ...
2019/08/11
[ "https://Stackoverflow.com/questions/57449963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7179457/" ]
If you are using RHEL 8 then you can use the subscription manager to get Ansible with the host and config file pre-built. Also, you will need to create an account on <https://developers.redhat.com> before you can do this: ``` subscription-manager register --auto-attach subscription-manager repos --enable ansible-2.8...
This worked for RHEL9 Should work for RHEL8 as well ``` [root@controller yum.repos.d]# yum list | grep ansible ansible-collection-microsoft-sql.noarch 1.1.1-3.el9_0 Local-AppStream ansible-collection-redhat-rhel_mgmt.noarch 1.0.0-2.el9 Local-AppSt...
7,330,279
I am writing a python interface to a c++ library and am wondering about the correct design of the library. I have found out (the hard way) that all methods passed to python must be declared static. If I understand correctly, this means that all functions basically must be defined in the same .cpp file. My interface ha...
2011/09/07
[ "https://Stackoverflow.com/questions/7330279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/446137/" ]
> > I have found out (the hard way) that all methods passed to python must > be declared static. If I understand correctly, this means that all > functions basically must be defined in the same .cpp file. My > interface has many functions, so this gets ugly very quickly. > > > Where did you find this out? It is...
Why do you say that all functions called by Python have to be static? It's usual for that to be the case, in order to avoid name conflicts (since any namespace, etc. will be ignored because of the `extern "C"`), but whether the function is static or not is of no consequence. When interfacing a library in C++, in my e...
7,542,421
[Python Challenge #2](http://www.pythonchallenge.com/pc/def/ocr.html) [Answer I found](http://ymcagodme.blogspot.com/2011/04/python-challenge-level-2.html) ``` FILE_PATH = 'l2-text' f = open(FILE_PATH) print ''.join([ t for t in f.read() if t.isalpha()]) f.close() ``` Question: Why is their a 't' before the for lo...
2011/09/24
[ "https://Stackoverflow.com/questions/7542421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/963081/" ]
`[t for t in f.read() if t.isalpha()]` is a list comprehension. Basically, it takes the given iterable (`f.read()`) and forms a list by taking all the elements read by applying an optional filter (the `if` clause) and a mapping function (the part on the left of the `for`). However, the mapping part is trivial here, th...
This is a [list comprehension](http://www.python.org/doc//current/tutorial/datastructures.html#list-comprehensions), not a `for`-loop. > > List comprehensions provide a concise way to create lists. > > > ``` [t for t in f.read() if t.isalpha()] ``` This creates a [`list`](http://www.python.org/doc//current/tuto...
7,542,421
[Python Challenge #2](http://www.pythonchallenge.com/pc/def/ocr.html) [Answer I found](http://ymcagodme.blogspot.com/2011/04/python-challenge-level-2.html) ``` FILE_PATH = 'l2-text' f = open(FILE_PATH) print ''.join([ t for t in f.read() if t.isalpha()]) f.close() ``` Question: Why is their a 't' before the for lo...
2011/09/24
[ "https://Stackoverflow.com/questions/7542421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/963081/" ]
This is a [list comprehension](http://www.python.org/doc//current/tutorial/datastructures.html#list-comprehensions), not a `for`-loop. > > List comprehensions provide a concise way to create lists. > > > ``` [t for t in f.read() if t.isalpha()] ``` This creates a [`list`](http://www.python.org/doc//current/tuto...
note the following is also valid: ``` print ''.join(( t for t in f.read() if t.isalpha())) ``` instead of [ and ] you have ( and ) This specifies a generator instead of a list. [generator comprehension](https://stackoverflow.com/questions/364802/generator-comprehension)
7,542,421
[Python Challenge #2](http://www.pythonchallenge.com/pc/def/ocr.html) [Answer I found](http://ymcagodme.blogspot.com/2011/04/python-challenge-level-2.html) ``` FILE_PATH = 'l2-text' f = open(FILE_PATH) print ''.join([ t for t in f.read() if t.isalpha()]) f.close() ``` Question: Why is their a 't' before the for lo...
2011/09/24
[ "https://Stackoverflow.com/questions/7542421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/963081/" ]
`[t for t in f.read() if t.isalpha()]` is a list comprehension. Basically, it takes the given iterable (`f.read()`) and forms a list by taking all the elements read by applying an optional filter (the `if` clause) and a mapping function (the part on the left of the `for`). However, the mapping part is trivial here, th...
note the following is also valid: ``` print ''.join(( t for t in f.read() if t.isalpha())) ``` instead of [ and ] you have ( and ) This specifies a generator instead of a list. [generator comprehension](https://stackoverflow.com/questions/364802/generator-comprehension)
57,077,432
I was trying to add two tuples two create a new sort of nested tuple using the coerce function of python. I'm using python version 3.7 which is showing that the function isn't defined. It is supposed to be a built-in function in python
2019/07/17
[ "https://Stackoverflow.com/questions/57077432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11797954/" ]
Including `Building` will also include `MultiApartmentBuilding` entries (in fact all types deriving from `Building`). You can use C# 7.0's pattern matching to test and cast at the same time (where `apartments` is the result of the query): ``` foreach (Apartment apartment in apartments) { // Access common Building...
You can't access the child's class attributes. In other words, if you have a Building, you can't access its **MultiApartmentBuilding** attributes, because you don't even know if it really is a **MultiApartmentBuilding**. What I would do in this case would be to change your **Apartment** class and use the type **MultiA...
24,452,972
Would like to extract all the lines from first file (GunZip \*.gz i.e Input.csv.gz), if the first file 4th field is falls within a range of Second file (Slab.csv) first field (Start Range) and second field (End Range) then populate Slab wise count of rows and sum of 4th and 5th field of first file. Input.csv.gz (GunZ...
2014/06/27
[ "https://Stackoverflow.com/questions/24452972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3350223/" ]
Here is one way using `awk` and `sort`: ``` awk ' BEGIN { FS = OFS = SUBSEP = ","; print "StartRange,EndRange,Count,Sum-4,Sum-5" } FNR == 1 { next } NR == FNR { ranges[$1,$2]++; next } { for (range in ranges) { split(range, tmp, SUBSEP); if ($4 >= tmp[1] && $4 <= tmp[2]) { ...
Here is another option using `perl` which takes benefits of creating multi-dimensional arrays and hashes. ``` perl -F, -lane' BEGIN { $x = pop; ## Create array of arrays from start and end ranges ## $range = ( [0,0] , [1,10] ... ) (undef, @range)= map { chomp; [split /,/] } <>; @ARGV = $x; } ## ...
44,335,494
So I downloaded Deuces, code for poker hand evaluations, and originally I think it was in Python 2, because all of the print statements had no parentheses. I fixed all of those, and everything seems to work, except this last part. Here is the code for it: ``` def get_lexographically_next_bit_sequence(self, bits): ...
2017/06/02
[ "https://Stackoverflow.com/questions/44335494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8062387/" ]
In accord with Arrivillaga's comment I had just modified what you had posted to this. ``` def get_lexographically_next_bit_sequence(bits): """ Bit hack from here: http://www-graphics.stanford.edu/~seander/bithacks.html#NextBitPermutation Generator even does this in poker order rank so no need to ...
It was the / symbol, as the gentleman said above it is supposed to be for floor division, and quick fix and it works fine.
69,217,390
I'm trying to build a website in python and flask however my CSS is not loading I don't see anything wrong with my code and I've tried the same code snippet from a few different sites. My Link: ```html <link rel="stylesheet" href="{{ url_for('static', filename= 'css/style.css') }}"> ``` File structure as below: [!...
2021/09/17
[ "https://Stackoverflow.com/questions/69217390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11386215/" ]
The problem was probably with the numpy function 'percentile' and how I passed in my argument to the find\_outliers\_tukey function. So these changes worked for me step 1 ====== 1. Include two arguments; one for the name of df, another for the name of the feature. 2. Put the feature argument into the df explicitly. 3...
For Question 1, your code seems to work fine on my end, but of course I don't have your original data. For Question 2, there are two problems. The first is that you are passing the column *names* to `find_outliers_tukey` instead of the columns themselves. Use `iteritems` to iterate over pairs of `(column name, column ...
54,695,126
I am trying to parse a webpage and print the link for items(href). Can you help with where am i going wrong? ``` import requests from bs4 import BeautifulSoup link = "https://www.amazon.in/Power- Banks/b/ref=nav_shopall_sbc_mobcomp_powerbank?ie=UTF8&node=6612025031" def amazon(url): sourcecode = requests.get(ur...
2019/02/14
[ "https://Stackoverflow.com/questions/54695126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4992020/" ]
You can though add headers. Then also when you do `find_all('a')`, you can just get it there is href: ``` import requests from bs4 import BeautifulSoup link = "https://www.amazon.in/Power-Banks/b/ref=nav_shopall_sbc_mobcomp_powerbank?ie=UTF8&node=6612025031" def amazon(url): headers = {'User-Agent': 'Mozilla/5.0...
If you tried to scrape Amazon right now with `requests` you won't get anything in return since Amazon will know that it's a script, and headers won't help it (as far as I know). Instead, in response they will tell the following: ``` To discuss automated access to Amazon data please contact api-services-support@amazon...
54,695,126
I am trying to parse a webpage and print the link for items(href). Can you help with where am i going wrong? ``` import requests from bs4 import BeautifulSoup link = "https://www.amazon.in/Power- Banks/b/ref=nav_shopall_sbc_mobcomp_powerbank?ie=UTF8&node=6612025031" def amazon(url): sourcecode = requests.get(ur...
2019/02/14
[ "https://Stackoverflow.com/questions/54695126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4992020/" ]
the problem in your code you are using wrong method name findALL .. There is no findALL method in soup object, so None is returned for that. to fix that use find\_all for new code , also findAll should work (with lower case double l). hope this clear things to you. ``` import requests from bs4 import BeautifulSoup li...
If you tried to scrape Amazon right now with `requests` you won't get anything in return since Amazon will know that it's a script, and headers won't help it (as far as I know). Instead, in response they will tell the following: ``` To discuss automated access to Amazon data please contact api-services-support@amazon...
52,788,039
I'm given a task to convert a **Perl script to Python**. I'm really new to Perl and understanding it where I came across a command line option which is `-Sx`. There is good documentation provided for these parameters in Perl. But there is no much documentation for the same in python (Didn't find much info in Python ...
2018/10/12
[ "https://Stackoverflow.com/questions/52788039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10496576/" ]
Questions I asked in a comment: > > Have you thought about if that bit of shell you were asking about is really necessary for what you're doing? Or are you just trying to blindly translate without understanding what things are doing? > > > I'm pretty sure the answers are no and yes respectively. That's not a go...
The following snippet is used to support ancient systems that predate the existence of `python`: ``` #!/bin/sh exec perl -Sx $0 ${1+"$@"} if 0; ``` Now, [it appears](https://stackoverflow.com/questions/52785232/what-does-exec-perl-perl-sx-0-1-mean-in-shell-script) that you are dealing with a bastardized and modif...
48,466,337
I have been working on creating a python GUI for some work. I would self-describe as a novice when it comes to by Python knowledge. I am using wxPython and wxGlade to help with the GUI development, as well. The problem is as follows: I have an empty TextCtrl object and a Button next to it. The Button is meant to ...
2018/01/26
[ "https://Stackoverflow.com/questions/48466337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9272739/" ]
As others have already pointed out, the way to go is by using the text control's `SetValue`. But here's a small runnable example: ``` import wx class MyPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) open_file_dlg_btn = wx.Button(self, label="Open FileDialog") ...
Try: ``` self.txtFeaturesPath.SetValue(pathname) ``` You have a few other buggy "features" in your example code, so watch out.
48,466,337
I have been working on creating a python GUI for some work. I would self-describe as a novice when it comes to by Python knowledge. I am using wxPython and wxGlade to help with the GUI development, as well. The problem is as follows: I have an empty TextCtrl object and a Button next to it. The Button is meant to ...
2018/01/26
[ "https://Stackoverflow.com/questions/48466337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9272739/" ]
As others have already pointed out, the way to go is by using the text control's `SetValue`. But here's a small runnable example: ``` import wx class MyPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) open_file_dlg_btn = wx.Button(self, label="Open FileDialog") ...
I realized that what I was assigning was not the value the fileDialog opens, but was instead the location in ram of the fileDialog object. the solution was the following ``` value = fileDialog.Directory + "\\" + fileDialog.filename self.txtFeaturesPath.SetValue(value) ``` thank you!
44,060,906
I just installed python-vlc via pip and when I try ``` import vlc ``` The follow error message shows up: ``` ... ... File "c:\Program Files\Python34\Lib\site-packages\vlc.py", line 173, in <module> dll, plugin_path = find_lib() File "c:\Program Files\Python34\Lib\site-packages\vlc.py", line 150, in find_lib dl...
2017/05/19
[ "https://Stackoverflow.com/questions/44060906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7970976/" ]
The problem has been solved. I was using 64 bit python and 32 bit VLC. Installing a 64 bit VLC program fixed the problem.
`python-vlc` on Windows needs to load `libvlc.dll` from VLC. If it's not found in the normal `%PATH%`, it will try to use `pywin32` to look in the registry to find the VLC install path, and fall back to a hard-coded set of directories after that. The stack trace looks like all of that failed. Do you have VLC installe...
44,060,906
I just installed python-vlc via pip and when I try ``` import vlc ``` The follow error message shows up: ``` ... ... File "c:\Program Files\Python34\Lib\site-packages\vlc.py", line 173, in <module> dll, plugin_path = find_lib() File "c:\Program Files\Python34\Lib\site-packages\vlc.py", line 150, in find_lib dl...
2017/05/19
[ "https://Stackoverflow.com/questions/44060906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7970976/" ]
`python-vlc` on Windows needs to load `libvlc.dll` from VLC. If it's not found in the normal `%PATH%`, it will try to use `pywin32` to look in the registry to find the VLC install path, and fall back to a hard-coded set of directories after that. The stack trace looks like all of that failed. Do you have VLC installe...
You are installed VLC 32 bit hence your path goes to program file (x86) and your code search the VLC file in programs file. That's why you are getting this error. To solve this problem we need to install VLC for 64 bits.
44,060,906
I just installed python-vlc via pip and when I try ``` import vlc ``` The follow error message shows up: ``` ... ... File "c:\Program Files\Python34\Lib\site-packages\vlc.py", line 173, in <module> dll, plugin_path = find_lib() File "c:\Program Files\Python34\Lib\site-packages\vlc.py", line 150, in find_lib dl...
2017/05/19
[ "https://Stackoverflow.com/questions/44060906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7970976/" ]
`python-vlc` on Windows needs to load `libvlc.dll` from VLC. If it's not found in the normal `%PATH%`, it will try to use `pywin32` to look in the registry to find the VLC install path, and fall back to a hard-coded set of directories after that. The stack trace looks like all of that failed. Do you have VLC installe...
I ran into the same problem. To fix it I actually had to install the x86 version **NOT** the x64bit version... no matter what I did it would not work. I figured this out through looking at the code it was using to find the path. Used a breakpoint to see what it was seeing in the exists flow and what it was searching : ...
44,060,906
I just installed python-vlc via pip and when I try ``` import vlc ``` The follow error message shows up: ``` ... ... File "c:\Program Files\Python34\Lib\site-packages\vlc.py", line 173, in <module> dll, plugin_path = find_lib() File "c:\Program Files\Python34\Lib\site-packages\vlc.py", line 150, in find_lib dl...
2017/05/19
[ "https://Stackoverflow.com/questions/44060906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7970976/" ]
The problem has been solved. I was using 64 bit python and 32 bit VLC. Installing a 64 bit VLC program fixed the problem.
You are installed VLC 32 bit hence your path goes to program file (x86) and your code search the VLC file in programs file. That's why you are getting this error. To solve this problem we need to install VLC for 64 bits.
44,060,906
I just installed python-vlc via pip and when I try ``` import vlc ``` The follow error message shows up: ``` ... ... File "c:\Program Files\Python34\Lib\site-packages\vlc.py", line 173, in <module> dll, plugin_path = find_lib() File "c:\Program Files\Python34\Lib\site-packages\vlc.py", line 150, in find_lib dl...
2017/05/19
[ "https://Stackoverflow.com/questions/44060906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7970976/" ]
The problem has been solved. I was using 64 bit python and 32 bit VLC. Installing a 64 bit VLC program fixed the problem.
I ran into the same problem. To fix it I actually had to install the x86 version **NOT** the x64bit version... no matter what I did it would not work. I figured this out through looking at the code it was using to find the path. Used a breakpoint to see what it was seeing in the exists flow and what it was searching : ...
68,036,975
**Done** I am just trying to run and replicate the following project: <https://machinelearningmastery.com/time-series-prediction-lstm-recurrent-neural-networks-python-keras/> . Basically until this point I have done everything as it is in the linked project but than I got the following issue: **My Own Dataset - I hav...
2021/06/18
[ "https://Stackoverflow.com/questions/68036975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10270590/" ]
I continue to see this problem in 2022 when using LSTMs or GRUs in Sagemaker with conda\_tensorflow2\_p38 kernel. Here's my workaround: Early in your notebook, before defining your model, set ``` tf.keras.backend.set_image_data_format("channels_last") ``` I know it looks weird to set image data format when you aren...
**Solution** * I switched to AWS EC2 SageMaker "Python [conda env:tensorflow2\_p36] " so this is the exact pre made environment "tensorflow2\_p36" * As I have read it in some other places it is probably library collision maybe with NumPy.
68,036,975
**Done** I am just trying to run and replicate the following project: <https://machinelearningmastery.com/time-series-prediction-lstm-recurrent-neural-networks-python-keras/> . Basically until this point I have done everything as it is in the linked project but than I got the following issue: **My Own Dataset - I hav...
2021/06/18
[ "https://Stackoverflow.com/questions/68036975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10270590/" ]
I continue to see this problem in 2022 when using LSTMs or GRUs in Sagemaker with conda\_tensorflow2\_p38 kernel. Here's my workaround: Early in your notebook, before defining your model, set ``` tf.keras.backend.set_image_data_format("channels_last") ``` I know it looks weird to set image data format when you aren...
I encountered same issue while using aws sagemaker. Changing lstm to tf.compat.v1.keras.layers.CuDNNLSTM worked for me. in your case: ``` model.add(LSTM(4, input_shape=(1, look_back))) ``` to ``` model.add(tf.compat.v1.keras.layers.CuDNNLSTM(4, input_shape=(1, look_back))) ```
30,284,611
I have a python web app that carry's out calculations on data you send to it via POST / GET parameters. The app works perfectly on my machine, but when deployed to openshift, it fails to access the parameters with an error no 32 : Broken pipe I then used this [quickstart](https://github.com/openshift-quickstart/flask-...
2015/05/17
[ "https://Stackoverflow.com/questions/30284611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1677589/" ]
Don't use Flask's development server in production. Use a proper WSGI server that can handle concurrent requests, like [Gunicorn](http://gunicorn.org/ "Gunicorn"). For now try turning on the server's threaded mode and see if it works. ``` app.run(host="x.x.x.x", port=1234, threaded=True) ```
You can get form data from the POST request via: ``` name = request.form.get("name") ``` Refactor: ``` @app.route('/', methods=['GET', 'POST']) def index(): if request.method == 'POST': name = request.form.get("name") result = "We received a POST request and the value for <name> ...
4,542,730
I have a app with a kind of rest api that I'm using to send emails . However it currently sends only text email so I need to know how to modify it and make it send html . Below is the code : ``` from __future__ import with_statement #!/usr/bin/env python # import cgi import os import logging import contextlib from ...
2010/12/27
[ "https://Stackoverflow.com/questions/4542730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/331071/" ]
Have a look to the [Email message fields](http://code.google.com/intl/it/appengine/docs/python/mail/emailmessagefields.html) of the `send_mail` function. Here is the parameter you need: > > **html** > > An HTML version of the body content, for recipients that prefer HTML email. > > > You should add the `h...
you can use the html field of EmailMessage class ``` message = mail.EmailMessage(sender=emailFrom,subject=emailSubject) message.to = emailTo message.body = emailBody message.html = emailHtml message.send() ```
73,906,061
Be the following python pandas DataFrame: | ID | country | money | code | money\_add | other | time | | --- | --- | --- | --- | --- | --- | --- | | 832932 | Other | NaN | 00000 | NaN | [N2,N2,N4] | 0 days 01:37:00 | | 217#8# | NaN | NaN | NaN | NaN | [N1,N2,N3] | 2 days 01:01:00 | | 1329T2 | France | 12131 | 00020 | 3...
2022/09/30
[ "https://Stackoverflow.com/questions/73906061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18396935/" ]
Because [`DataFrame.update`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.update.html) not working well here is alternative - first use left join for new columns from second DataFrame by [`DataFrame.merge`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.merge.ht...
This is another method different from Jezrael's, but you can try it out. You can first create a condition variable for your dataframe. ``` condition = (df.code.isin(df1.cod_t) & ~df.code.isnull() & df.money.isna()) columns = ['money', 'money_add'] ``` Next, use `df.loc` to do the update. ``` df.loc[condition, colu...
43,006,368
I am trying to connect to AWS Athena using python. I am trying to use pyathenajdbc to achieve this task. The issue I am having is obtaining a connection. When I run the code below, I receive an error message stating it cannot find the AthenaDriver. ( java.lang.RuntimeException: Class com.amazonaws.athena.jdbc.AthenaDri...
2017/03/24
[ "https://Stackoverflow.com/questions/43006368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3389780/" ]
The JDBC driver requires Java 8. I was currently running Java 7. I was able to install another version of Java on EC2 instance. <https://tecadmin.net/install-java-8-on-centos-rhel-and-fedora/#> I had to also set the java version in my code. With these changes, the code now runs as expected. ``` from mdpbi.rsi.confi...
Try this : ``` pyathenajdbc.ATHENA_JAR = ATHENA_JDBC_CLASSPATH ``` You won't be needing to specify the driver\_path argument in the connection method
59,986,413
I'm trying to use the new python dataclasses to create some mix-in classes (already as I write this I think it sounds like a rash idea), and I'm having some issues. Behold the example below: ```py from dataclasses import dataclass @dataclass class NamedObj: name: str def __post_init__(self): print("N...
2020/01/30
[ "https://Stackoverflow.com/questions/59986413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9112585/" ]
This: ``` def __post_init__(self): super(NamedObj, self).__post_init__() super(NumberedObj, self).__post_init__() print("NamedAndNumbered __post_init__") ``` doesn't do what you think it does. `super(cls, obj)` will return a proxy to the class **after** `cls` in `type(obj).__mro__` - so, in your case, to...
The problem (most probably) isn't related to `dataclass`es. The problem is in Python's [method resolution](http://python-history.blogspot.com/2010/06/method-resolution-order.html). Calling method on `super()` invokes the first found method from parent class in the [MRO](https://www.python.org/download/releases/2.3/mro/...
38,913,502
I am trying to install a python package on my ubuntu.I am trying to install it through a setup script which i had written.The setup.py script looks like this: ``` from setuptools import setup try: from setuptools import setup except ImportError: from distutils.core import setup setup( name = 'pyduino...
2016/08/12
[ "https://Stackoverflow.com/questions/38913502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5507861/" ]
Try install your packages with pip using this ``` pip install --install-option="--prefix=$PREFIX_PATH" package_name ``` as described here [Install a Python package into a different directory using pip?](https://stackoverflow.com/questions/2915471/install-a-python-package-into-a-different-directory-using-pip) and i...
Currently, you're using a `scripts` tag to install your python code. This will put your code in `/usr/local/bin`, which is not in `PYTHONPATH`. According to [the documentation](https://docs.python.org/2/distutils/setupscript.html), you use `scripts` when you want to install executable scripts (stuff you want to call f...
49,355,434
How do I navigate to another webpage using the same driver with Selenium in python? I do not want to open a new page. I want to keep on using the same driver. I thought that the following would work: ``` driver.navigate().to("https://support.tomtom.com/app/contact/") ``` But it doesn't! Navigate seems not to be a 'W...
2018/03/19
[ "https://Stackoverflow.com/questions/49355434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3623123/" ]
To navigate to a webpage you just write ``` driver.get(__url__) ``` you can do this in your program multiple times
The line of code which you have tried as : ``` driver.navigate().to("https://support.tomtom.com/app/contact/") ``` It is a typical *Java* based line of code. However as per the currect **Python API Docs** of [The WebDriver implementation](https://seleniumhq.github.io/selenium/docs/api/py/webdriver_remote/selenium.w...
23,726,365
I'm using tweepy and trying to run the basic script as shown by this [video](https://www.youtube.com/watch?v=pUUxmvvl2FE). I was previously receiving 401 errors (unsynchronized time zones) but am using the provided keys. I fixed that problem and now I'm getting this result: ``` Traceback (most recent call last): ...
2014/05/18
[ "https://Stackoverflow.com/questions/23726365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1472645/" ]
Turns out the solution is simply to wait a day. Who would've thought!
I was also getting same error while using the python-twitter module in my script but it got resolved automatically when I tried after an interval. As there is limit for the number of try at a particular interval hence we get this error when we exceed that maximum try limit.
33,340,442
I am trying to post [some data via ajax](http://jsfiddle.net/g1wvryp7/) to our backend API, but the arrays within the json data get turned into weird things by jquery...for example, the backend (python) sees the jquery ajax data as a dict of two lists ``` {'subject': ['something'], 'members[]': ['joe','bob']} ``` ...
2015/10/26
[ "https://Stackoverflow.com/questions/33340442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1449443/" ]
That shouldnt be a problem since you only pass the reference to that list to other objects. That means you have only one big list. But you should be aware that every object that has a reference to that list can change it
Well in Java, you only pass object "by reference"... From the link in the comments: > > Let’s be a little bit more specific by what we mean here: objects are > passed by reference – meaning that a reference/memory address is > passed when an object is assigned to another – BUT (and this is what’s > important) tha...
62,733,213
I'm trying to figure out how to read a file from Azure blob storage. Studying its documentation, I can see that the [download\_blob](https://learn.microsoft.com/en-us/python/api/azure-storage-blob/azure.storage.blob.blobclient?view=azure-python#download-blob-offset-none--length-none----kwargs-) method seems to be the ...
2020/07/04
[ "https://Stackoverflow.com/questions/62733213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1255356/" ]
**Update 0710:** In the latest SDK [azure-storage-blob 12.3.2](https://pypi.org/project/azure-storage-blob/), we can also do the same thing by using `download_blob`. The screenshot of the source code of `download_blob`: [![enter image description here](https://i.stack.imgur.com/eFH3j.jpg)](https://i.stack.imgur.com/...
The accepted answer [here](https://stackoverflow.com/questions/33091830/how-best-to-convert-from-azure-blob-csv-format-to-pandas-dataframe-while-running) may be of use to you. The documentation can be found [here](https://learn.microsoft.com/en-us/python/api/azure-storage-blob/azure.storage.blob.baseblobservice.baseblo...
23,201,351
I know this is a basic question, but I'm new to python and can't figure out how to solve it. I have a list like the next example: ``` entities = ["#1= IFCORGANIZATION($,'Autodesk Revit 2014 (ENU)',$,$,$)";, "#5= IFCAPPLICATION(#1,'2014','Autodesk Revit 2014 (ENU)','Revit');"] ``` My problem is how to add the infor...
2014/04/21
[ "https://Stackoverflow.com/questions/23201351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3556883/" ]
If you want to know if a value is in a list you can use `in`, like this: ``` >>> my_list = ["one", "two", "three"] >>> "two" in my_list True >>> ``` If you need to get the position of the value in the list you must use `index`: ``` >>> my_list.index("two") 1 >>> ``` Note that the first element of the list has ...
Here you go: ``` >>> import re >>> import ast >>> entities = ["#1= IFCORGANIZATION('$','Autodesk Revit 2014 (ENU)','$','$','$');", "#5= IFCAPPLICATION('#1','2014','Autodesk Revit 2014 (ENU)','Revit');"] >>> entities = [a.strip(';') for a in entities] >>> pattern = re.compile(r'\((.*)\)') >>> dic = {} >>> for a in enti...
23,201,351
I know this is a basic question, but I'm new to python and can't figure out how to solve it. I have a list like the next example: ``` entities = ["#1= IFCORGANIZATION($,'Autodesk Revit 2014 (ENU)',$,$,$)";, "#5= IFCAPPLICATION(#1,'2014','Autodesk Revit 2014 (ENU)','Revit');"] ``` My problem is how to add the infor...
2014/04/21
[ "https://Stackoverflow.com/questions/23201351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3556883/" ]
If you want to know if a value is in a list you can use `in`, like this: ``` >>> my_list = ["one", "two", "three"] >>> "two" in my_list True >>> ``` If you need to get the position of the value in the list you must use `index`: ``` >>> my_list.index("two") 1 >>> ``` Note that the first element of the list has ...
You could use [`str.split`](https://docs.python.org/2/library/stdtypes.html#str.split) to deal with strings. First split each element string with `'('`, with maxsplit being 1: ``` In [48]: dic=dict(e[:-1].split('(', 1) for e in entities) #using [:-1] to filter out ')' ...: print dic ...: {'#5= IFCAPPLICATION'...
23,201,351
I know this is a basic question, but I'm new to python and can't figure out how to solve it. I have a list like the next example: ``` entities = ["#1= IFCORGANIZATION($,'Autodesk Revit 2014 (ENU)',$,$,$)";, "#5= IFCAPPLICATION(#1,'2014','Autodesk Revit 2014 (ENU)','Revit');"] ``` My problem is how to add the infor...
2014/04/21
[ "https://Stackoverflow.com/questions/23201351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3556883/" ]
You could use [`str.split`](https://docs.python.org/2/library/stdtypes.html#str.split) to deal with strings. First split each element string with `'('`, with maxsplit being 1: ``` In [48]: dic=dict(e[:-1].split('(', 1) for e in entities) #using [:-1] to filter out ')' ...: print dic ...: {'#5= IFCAPPLICATION'...
Here you go: ``` >>> import re >>> import ast >>> entities = ["#1= IFCORGANIZATION('$','Autodesk Revit 2014 (ENU)','$','$','$');", "#5= IFCAPPLICATION('#1','2014','Autodesk Revit 2014 (ENU)','Revit');"] >>> entities = [a.strip(';') for a in entities] >>> pattern = re.compile(r'\((.*)\)') >>> dic = {} >>> for a in enti...
69,637,510
I try to add a local KVM maschine dynamically to ansible inventory with ansible 2.11.6. ``` ansible [core 2.11.6] config file = /home/ansible/ansible.cfg configured module search path = ['/home/ansible/library'] ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible ansible collection ...
2021/10/19
[ "https://Stackoverflow.com/questions/69637510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8478100/" ]
Next.js is a framework for React which helps developers manage Server-Side Rendering in react. There are many benefits of server-side rendering including: caching specific pages (or caching only what is public and keeping user-specific data or auth-required data to be loaded on the frontend). Since Next.js is doing s...
If this code is run on the server as part of [pre-rendering](https://nextjs.org/docs/basic-features/pages#pre-rendering) (either server-side rendering or static rendering), there will be no `window` (and hence no `window.btoa` for base64-encoding) since there is no browser, but instead node.js's `Buffer` can be utilize...
70,290,737
i tried to use this command in cmd to install module certifi: ``` pip install certifi ``` But it throws some warning like this: ``` WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) ``` How can i fix it and install certifi ? (Python 3.9.6 )
2021/12/09
[ "https://Stackoverflow.com/questions/70290737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17291416/" ]
there is no question in your title nor in description, some mathematical resolution to your problem could be to put numbers to your directions, for example up=1 down=-1 left=2 right=-2 and then on keypress to change direction check: ``` if not actualPosition + newPosition: #dont do anything since collision else: ...
You can check if the new direction is different from the old one. If it is diffrent, you update the direction, otherwise you keep the same direction: ``` def new_dir(self, new_dir): return new_dir if new_dir != self.direction else self.direction def move_up(self): self.direction = self.ne...
70,290,737
i tried to use this command in cmd to install module certifi: ``` pip install certifi ``` But it throws some warning like this: ``` WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) ``` How can i fix it and install certifi ? (Python 3.9.6 )
2021/12/09
[ "https://Stackoverflow.com/questions/70290737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17291416/" ]
That's how I'd do it. It avoids walking into itself and also prevents doing "fake" turns into the direction you are already following. ``` def new_dir(self, direction): if self.direction == "up" or self.direction == "down": if direction == "left": self.move_left() if direction == "right...
there is no question in your title nor in description, some mathematical resolution to your problem could be to put numbers to your directions, for example up=1 down=-1 left=2 right=-2 and then on keypress to change direction check: ``` if not actualPosition + newPosition: #dont do anything since collision else: ...
70,290,737
i tried to use this command in cmd to install module certifi: ``` pip install certifi ``` But it throws some warning like this: ``` WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) ``` How can i fix it and install certifi ? (Python 3.9.6 )
2021/12/09
[ "https://Stackoverflow.com/questions/70290737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17291416/" ]
```py def move_up(self): if direction != "down": self.direction = "up" def move_down(self): if self.direction != "up": self.direction = "down" def move_right(self): if self.direction != "left": self.direction = "right" def move_left(self): if self.direction != "right": ...
You can check if the new direction is different from the old one. If it is diffrent, you update the direction, otherwise you keep the same direction: ``` def new_dir(self, new_dir): return new_dir if new_dir != self.direction else self.direction def move_up(self): self.direction = self.ne...
70,290,737
i tried to use this command in cmd to install module certifi: ``` pip install certifi ``` But it throws some warning like this: ``` WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) ``` How can i fix it and install certifi ? (Python 3.9.6 )
2021/12/09
[ "https://Stackoverflow.com/questions/70290737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17291416/" ]
That's how I'd do it. It avoids walking into itself and also prevents doing "fake" turns into the direction you are already following. ``` def new_dir(self, direction): if self.direction == "up" or self.direction == "down": if direction == "left": self.move_left() if direction == "right...
You can check if the new direction is different from the old one. If it is diffrent, you update the direction, otherwise you keep the same direction: ``` def new_dir(self, new_dir): return new_dir if new_dir != self.direction else self.direction def move_up(self): self.direction = self.ne...
70,290,737
i tried to use this command in cmd to install module certifi: ``` pip install certifi ``` But it throws some warning like this: ``` WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) ``` How can i fix it and install certifi ? (Python 3.9.6 )
2021/12/09
[ "https://Stackoverflow.com/questions/70290737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17291416/" ]
That's how I'd do it. It avoids walking into itself and also prevents doing "fake" turns into the direction you are already following. ``` def new_dir(self, direction): if self.direction == "up" or self.direction == "down": if direction == "left": self.move_left() if direction == "right...
```py def move_up(self): if direction != "down": self.direction = "up" def move_down(self): if self.direction != "up": self.direction = "down" def move_right(self): if self.direction != "left": self.direction = "right" def move_left(self): if self.direction != "right": ...
32,277,153
I'm using wxpython to code this simple form. A notebook with a scroll bar and few text controls is what i have used.I can see the widgets which are view-able on screen but the ones which needs to be scrolled down are not visible. In my code below i could see upto "Enter the Logs" and appropriate text control for that f...
2015/08/28
[ "https://Stackoverflow.com/questions/32277153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4672258/" ]
Your Java application is going to run in a Linux container, so you can use any Linux or Java method of setting the timezone. The easy ones that come to mind... `cf set-env <app-name> TZ 'America/Los_Angeles' cf restage <app-name>` or `cf set-env <app-name> JAVA_OPTS '-Duser.timezone=Europe/Sofia' cf restage <app-na...
To expand on @DanielMikusa. (Great Answer) SAMPLE MANIFEST: ``` applications: - path: . buildpack: nodejs_buildpack memory: 128M instances: 1 name: sampleCronJobService health-check-type: process disk_quota: 1024M env: TZ: Etc/Greenwich CF_STAGING_TIMEOUT: 15 CF_STARTUP_TIMEOUT: 15 T...
50,238,512
I have installed virtualenv on my system using <http://www.pythonforbeginners.com/basics/how-to-use-python-virtualenv> according to these [guidelines](http://blog.niandrei.com/2016/03/01/install-tensorflow-on-ubuntu-with-virtualenv/#comment-21), the initial step is: $ sudo apt-get install python-pip python-dev python...
2018/05/08
[ "https://Stackoverflow.com/questions/50238512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9332343/" ]
Have you noted that in the screen shot you're using version 2.5 in the references for the OpenXml assembly, but the exception message is referencing the newer 2.7.2? That could be your issue. It could be that you've referenced 2.5, but the "ClosedXML" is expecting 2.7.2 and when it doesn't find it tosses an error? I w...
you have to go to nugget and update the document xml reference to the latest one which is 2.7 and the issue is fixed
65,871,734
**Update: I let-rally tried 12 suggested solutions but nothing worked at all.** Is my question missing any details? The suggested answer doesn't solve the problem In python I wrote: ``` print(s.cookies.get_dict()) ``` where s is my session, the output is: ``` {'lubl': 'https%3A%2F%2Fopenworld.com%2Fconfirm', 'rish...
2021/01/24
[ "https://Stackoverflow.com/questions/65871734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What you are looking for is [`pandas.DataFrame.applymap`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.applymap.html), which applies a function element-wise: ``` df.applymap(lambda x: -1 if x < low else (1 if x > high else 0)) ``` The method [`pandas.DataFrame.apply`](https://pandas.py...
You are sending the lambda the full dataframe, but you need to send it a column: ``` for col in df.columns: df[col].apply(lambda x: -1 if x < low else (1 if x > high else 0)) ```
56,105,090
I'm trying to upload a file using the built in wagtaildocs application in my Wagtail application. I've setup my Ubuntu 16.04 server was setup with the Digital Ocean tutorial methods for Nginx | Gunicorn | Postgres Some initial clarifications: 1. In my Nginx config I've set `client_max_body_size` 10000M; 2. In my prod...
2019/05/13
[ "https://Stackoverflow.com/questions/56105090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11490399/" ]
I was never able to solve this problem directly, but I did come up with a hack to get around it. I'm not a Wagtail or Django expert so I'm sure there is a proper solution to this answer, but anyway here's what I did. If you have any recommendations on improvement feel free to leave a comment. As a note this is really...
I would suspect that the exception `psycopg2.DatabaseError SSL SYSCALL error: Operation timed out` will happen if the droplet is running out of memory. Try to create a swap partition or extend your memory. [Creating a swap partition](https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-16...
9,301,531
Why doesn't the following work? ``` $ alias sayHello='/bin/echo "Hello world!"' $ sayHello Hello world! $ nohup sayHello nohup: appending output to `nohup.out' nohup: cannot run command `sayHello': No such file or directory ``` (the reason I ask this question is because I've aliased my `perl` and `pyth...
2012/02/15
[ "https://Stackoverflow.com/questions/9301531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/884447/" ]
Because the shell doesn't pass aliases on to child processes (except when you use $() or ``). $ alias sayHello='/bin/echo "Hello world!"' Now an alias is known in this shell process, which is fine but only works in this one shell process. ``` $ sayHello Hello world! ``` Since you said "sayHello" in the same shel...
If you look at the [Aliases](http://www.gnu.org/software/bash/manual/html_node/Aliases.html) section of the Bash manual, it says > > The first word of each simple command, if unquoted, is checked to see > if it has an alias. > > > Unfortunately, it doesn't seem like `bash` has anything like `zsh`'s [global alias...
9,301,531
Why doesn't the following work? ``` $ alias sayHello='/bin/echo "Hello world!"' $ sayHello Hello world! $ nohup sayHello nohup: appending output to `nohup.out' nohup: cannot run command `sayHello': No such file or directory ``` (the reason I ask this question is because I've aliased my `perl` and `pyth...
2012/02/15
[ "https://Stackoverflow.com/questions/9301531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/884447/" ]
Because the shell doesn't pass aliases on to child processes (except when you use $() or ``). $ alias sayHello='/bin/echo "Hello world!"' Now an alias is known in this shell process, which is fine but only works in this one shell process. ``` $ sayHello Hello world! ``` Since you said "sayHello" in the same shel...
For bash: Try doing nohup '`your_alias`'. It works for me. I don't know why back quote is not shown. Put your alias within back quotes.
9,301,531
Why doesn't the following work? ``` $ alias sayHello='/bin/echo "Hello world!"' $ sayHello Hello world! $ nohup sayHello nohup: appending output to `nohup.out' nohup: cannot run command `sayHello': No such file or directory ``` (the reason I ask this question is because I've aliased my `perl` and `pyth...
2012/02/15
[ "https://Stackoverflow.com/questions/9301531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/884447/" ]
Because the shell doesn't pass aliases on to child processes (except when you use $() or ``). $ alias sayHello='/bin/echo "Hello world!"' Now an alias is known in this shell process, which is fine but only works in this one shell process. ``` $ sayHello Hello world! ``` Since you said "sayHello" in the same shel...
With bash, you can invoke a subshell interactively using the `-i` option. This will source your `.bashrc` as well as enable the `expand_aliases` shell option. Granted, this will only work if your *alias* is defined in your `.bashrc` which is the convention. **Bash manpage:** > > If the `-i` option is present, the sh...
9,301,531
Why doesn't the following work? ``` $ alias sayHello='/bin/echo "Hello world!"' $ sayHello Hello world! $ nohup sayHello nohup: appending output to `nohup.out' nohup: cannot run command `sayHello': No such file or directory ``` (the reason I ask this question is because I've aliased my `perl` and `pyth...
2012/02/15
[ "https://Stackoverflow.com/questions/9301531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/884447/" ]
For bash: Try doing nohup '`your_alias`'. It works for me. I don't know why back quote is not shown. Put your alias within back quotes.
If you look at the [Aliases](http://www.gnu.org/software/bash/manual/html_node/Aliases.html) section of the Bash manual, it says > > The first word of each simple command, if unquoted, is checked to see > if it has an alias. > > > Unfortunately, it doesn't seem like `bash` has anything like `zsh`'s [global alias...
9,301,531
Why doesn't the following work? ``` $ alias sayHello='/bin/echo "Hello world!"' $ sayHello Hello world! $ nohup sayHello nohup: appending output to `nohup.out' nohup: cannot run command `sayHello': No such file or directory ``` (the reason I ask this question is because I've aliased my `perl` and `pyth...
2012/02/15
[ "https://Stackoverflow.com/questions/9301531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/884447/" ]
With bash, you can invoke a subshell interactively using the `-i` option. This will source your `.bashrc` as well as enable the `expand_aliases` shell option. Granted, this will only work if your *alias* is defined in your `.bashrc` which is the convention. **Bash manpage:** > > If the `-i` option is present, the sh...
If you look at the [Aliases](http://www.gnu.org/software/bash/manual/html_node/Aliases.html) section of the Bash manual, it says > > The first word of each simple command, if unquoted, is checked to see > if it has an alias. > > > Unfortunately, it doesn't seem like `bash` has anything like `zsh`'s [global alias...
9,301,531
Why doesn't the following work? ``` $ alias sayHello='/bin/echo "Hello world!"' $ sayHello Hello world! $ nohup sayHello nohup: appending output to `nohup.out' nohup: cannot run command `sayHello': No such file or directory ``` (the reason I ask this question is because I've aliased my `perl` and `pyth...
2012/02/15
[ "https://Stackoverflow.com/questions/9301531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/884447/" ]
For bash: Try doing nohup '`your_alias`'. It works for me. I don't know why back quote is not shown. Put your alias within back quotes.
With bash, you can invoke a subshell interactively using the `-i` option. This will source your `.bashrc` as well as enable the `expand_aliases` shell option. Granted, this will only work if your *alias* is defined in your `.bashrc` which is the convention. **Bash manpage:** > > If the `-i` option is present, the sh...
21,822,054
I've tried what's told in [How to force /bin/bash interpreter for oneliners](https://stackoverflow.com/questions/20906073/how-to-force-bin-bash-interpreter-for-oneliners) By doing ``` os.system('GREPDB="my command"') os.system('/bin/bash -c \'$GREPDB\'') ``` However no luck, unfortunately I need to run this comman...
2014/02/17
[ "https://Stackoverflow.com/questions/21822054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2453153/" ]
Both commands are executed in different subshells. Setting variables in the first `system` call does not affect the second `system` call. You need to put two command in one string (combining them with `;`). ``` >>> import os >>> os.system('GREPDB="echo 123"; /bin/bash -c "$GREPDB"') 123 0 ``` **NOTE** You need to...
The solution below still initially invokes a shell, but it switches to bash for the command you are trying to execute: ``` os.system('/bin/bash -c "echo hello world"') ```
21,822,054
I've tried what's told in [How to force /bin/bash interpreter for oneliners](https://stackoverflow.com/questions/20906073/how-to-force-bin-bash-interpreter-for-oneliners) By doing ``` os.system('GREPDB="my command"') os.system('/bin/bash -c \'$GREPDB\'') ``` However no luck, unfortunately I need to run this comman...
2014/02/17
[ "https://Stackoverflow.com/questions/21822054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2453153/" ]
Both commands are executed in different subshells. Setting variables in the first `system` call does not affect the second `system` call. You need to put two command in one string (combining them with `;`). ``` >>> import os >>> os.system('GREPDB="echo 123"; /bin/bash -c "$GREPDB"') 123 0 ``` **NOTE** You need to...
I use this: ``` subprocess.call(["bash","-c",cmd]) ``` //OK, ignore this because I have not notice subprocess not considered.
21,822,054
I've tried what's told in [How to force /bin/bash interpreter for oneliners](https://stackoverflow.com/questions/20906073/how-to-force-bin-bash-interpreter-for-oneliners) By doing ``` os.system('GREPDB="my command"') os.system('/bin/bash -c \'$GREPDB\'') ``` However no luck, unfortunately I need to run this comman...
2014/02/17
[ "https://Stackoverflow.com/questions/21822054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2453153/" ]
Both commands are executed in different subshells. Setting variables in the first `system` call does not affect the second `system` call. You need to put two command in one string (combining them with `;`). ``` >>> import os >>> os.system('GREPDB="echo 123"; /bin/bash -c "$GREPDB"') 123 0 ``` **NOTE** You need to...
I searched this command for some days and found really working code: ``` import subprocess def bash_command(cmd): subprocess.Popen(['/bin/bash', '-c', cmd]) code="abcde" // you can use echo options such as -e bash_command('echo -ne "'+code+'"') ``` Output: ``` abcde ```
21,822,054
I've tried what's told in [How to force /bin/bash interpreter for oneliners](https://stackoverflow.com/questions/20906073/how-to-force-bin-bash-interpreter-for-oneliners) By doing ``` os.system('GREPDB="my command"') os.system('/bin/bash -c \'$GREPDB\'') ``` However no luck, unfortunately I need to run this comman...
2014/02/17
[ "https://Stackoverflow.com/questions/21822054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2453153/" ]
Both commands are executed in different subshells. Setting variables in the first `system` call does not affect the second `system` call. You need to put two command in one string (combining them with `;`). ``` >>> import os >>> os.system('GREPDB="echo 123"; /bin/bash -c "$GREPDB"') 123 0 ``` **NOTE** You need to...
``` subprocess.Popen(cmd, shell=True, executable='/bin/bash') ```
21,822,054
I've tried what's told in [How to force /bin/bash interpreter for oneliners](https://stackoverflow.com/questions/20906073/how-to-force-bin-bash-interpreter-for-oneliners) By doing ``` os.system('GREPDB="my command"') os.system('/bin/bash -c \'$GREPDB\'') ``` However no luck, unfortunately I need to run this comman...
2014/02/17
[ "https://Stackoverflow.com/questions/21822054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2453153/" ]
The solution below still initially invokes a shell, but it switches to bash for the command you are trying to execute: ``` os.system('/bin/bash -c "echo hello world"') ```
I use this: ``` subprocess.call(["bash","-c",cmd]) ``` //OK, ignore this because I have not notice subprocess not considered.
21,822,054
I've tried what's told in [How to force /bin/bash interpreter for oneliners](https://stackoverflow.com/questions/20906073/how-to-force-bin-bash-interpreter-for-oneliners) By doing ``` os.system('GREPDB="my command"') os.system('/bin/bash -c \'$GREPDB\'') ``` However no luck, unfortunately I need to run this comman...
2014/02/17
[ "https://Stackoverflow.com/questions/21822054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2453153/" ]
The solution below still initially invokes a shell, but it switches to bash for the command you are trying to execute: ``` os.system('/bin/bash -c "echo hello world"') ```
I searched this command for some days and found really working code: ``` import subprocess def bash_command(cmd): subprocess.Popen(['/bin/bash', '-c', cmd]) code="abcde" // you can use echo options such as -e bash_command('echo -ne "'+code+'"') ``` Output: ``` abcde ```
21,822,054
I've tried what's told in [How to force /bin/bash interpreter for oneliners](https://stackoverflow.com/questions/20906073/how-to-force-bin-bash-interpreter-for-oneliners) By doing ``` os.system('GREPDB="my command"') os.system('/bin/bash -c \'$GREPDB\'') ``` However no luck, unfortunately I need to run this comman...
2014/02/17
[ "https://Stackoverflow.com/questions/21822054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2453153/" ]
The solution below still initially invokes a shell, but it switches to bash for the command you are trying to execute: ``` os.system('/bin/bash -c "echo hello world"') ```
``` subprocess.Popen(cmd, shell=True, executable='/bin/bash') ```
21,822,054
I've tried what's told in [How to force /bin/bash interpreter for oneliners](https://stackoverflow.com/questions/20906073/how-to-force-bin-bash-interpreter-for-oneliners) By doing ``` os.system('GREPDB="my command"') os.system('/bin/bash -c \'$GREPDB\'') ``` However no luck, unfortunately I need to run this comman...
2014/02/17
[ "https://Stackoverflow.com/questions/21822054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2453153/" ]
I use this: ``` subprocess.call(["bash","-c",cmd]) ``` //OK, ignore this because I have not notice subprocess not considered.
I searched this command for some days and found really working code: ``` import subprocess def bash_command(cmd): subprocess.Popen(['/bin/bash', '-c', cmd]) code="abcde" // you can use echo options such as -e bash_command('echo -ne "'+code+'"') ``` Output: ``` abcde ```
21,822,054
I've tried what's told in [How to force /bin/bash interpreter for oneliners](https://stackoverflow.com/questions/20906073/how-to-force-bin-bash-interpreter-for-oneliners) By doing ``` os.system('GREPDB="my command"') os.system('/bin/bash -c \'$GREPDB\'') ``` However no luck, unfortunately I need to run this comman...
2014/02/17
[ "https://Stackoverflow.com/questions/21822054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2453153/" ]
I use this: ``` subprocess.call(["bash","-c",cmd]) ``` //OK, ignore this because I have not notice subprocess not considered.
``` subprocess.Popen(cmd, shell=True, executable='/bin/bash') ```
21,822,054
I've tried what's told in [How to force /bin/bash interpreter for oneliners](https://stackoverflow.com/questions/20906073/how-to-force-bin-bash-interpreter-for-oneliners) By doing ``` os.system('GREPDB="my command"') os.system('/bin/bash -c \'$GREPDB\'') ``` However no luck, unfortunately I need to run this comman...
2014/02/17
[ "https://Stackoverflow.com/questions/21822054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2453153/" ]
``` subprocess.Popen(cmd, shell=True, executable='/bin/bash') ```
I searched this command for some days and found really working code: ``` import subprocess def bash_command(cmd): subprocess.Popen(['/bin/bash', '-c', cmd]) code="abcde" // you can use echo options such as -e bash_command('echo -ne "'+code+'"') ``` Output: ``` abcde ```
14,402,654
extreme python/sql beginner here. I've looked around for some help with this but wasn't able to find exactly what I need- would really appreciate any assistance. As the title indicates, I have a very large text file that I want to parse into a sql database preferably using python. The text file is set up as so: ``` ...
2013/01/18
[ "https://Stackoverflow.com/questions/14402654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1756574/" ]
A few points: 1. From the description it seems like you aim at your data being denormalized in one table. This is generally not a good idea. Split your data into two tables: PARENT and CHILDREN. PARENT should contain ID and CHILDREN should have at least two columns: PARENT\_ID and CHILD\_VALUE (or smth like it) with P...
you should look into **file handling** in python. the `open() , .readlines()` methods and lists will help you **alot**. for example: ``` f = open("NAMEOFTXTFILE.TXT","r") #r for read, w for write, a for append. cell = f.readlines() # Displays the content in a list f.seek(0) # Just takes the cursor to the first cell ...
36,064,495
currently I need to make some distance calculation. For this I am trying the following on my ipython-notebook (version 4.0.4): ``` from geopy.distance import vincenty ig_gruendau = (50.195883, 9.115557) delphi = (49.99908,19.84481) print(vincenty(ig_gruendau,delphi).miles) ``` Unfortunately I receive the following...
2016/03/17
[ "https://Stackoverflow.com/questions/36064495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5446609/" ]
You need to install the missing module in your python installation. So you have to run the command: ``` pip install geopy ``` in your terminal. If you don't have pip, you'll have to install it using: ``` easy_install pip ``` and if both command fail with `Permission denied`, then you'll have to either launch the ...
Even if you install using `pip install` command you still have to use: ``` conda install -c conda-forge geopy ``` This command is in the anaconda server so that it gets installed in the anaconda.
34,013,185
Let's say that I have this list in python ``` A = ["(a,1)", "(b,2)", "(c,3)", "(d,4)"] ``` so how can I print it out in the following format: ``` (a,1), (b,2), (c,3), (d,4) ``` using one line, better without using for loop Thanks in advance
2015/12/01
[ "https://Stackoverflow.com/questions/34013185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5482492/" ]
When A is a list of str: ``` print(', '.join(A)) ``` Or more general: ``` print(', '.join(map(str, A))) ```
In your case below code will work ``` print(', '.join(A)) ```
34,013,185
Let's say that I have this list in python ``` A = ["(a,1)", "(b,2)", "(c,3)", "(d,4)"] ``` so how can I print it out in the following format: ``` (a,1), (b,2), (c,3), (d,4) ``` using one line, better without using for loop Thanks in advance
2015/12/01
[ "https://Stackoverflow.com/questions/34013185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5482492/" ]
When A is a list of str: ``` print(', '.join(A)) ``` Or more general: ``` print(', '.join(map(str, A))) ```
You can also use regular expression: ``` >>> A = ["(a,1)", "(b,2)", "(c,3)", "(d,4)"] >>> import re >>> re.sub(r'[\[\]\"]', r"",",".join(A)) '(a,1),(b,2),(c,3),(d,4)' ```
49,514,684
I'm relatively new to using sklearn and python for data analysis and am trying to run some linear regression on a dataset that I loaded from a `.csv` file. I have loaded my data into `train_test_split` without any issues, but when I try to fit my training data I receive an error `ValueError: Expected 2D array, got 1D ...
2018/03/27
[ "https://Stackoverflow.com/questions/49514684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1061892/" ]
You are only using one feature, so it tells you what to do within the error: > > Reshape your data either using array.reshape(-1, 1) if your data has a single feature. > > > The data always has to be 2D in scikit-learn. (Don't forget the typo in `X = organic['Sunglight']`)
Once you load the data into `train_test_split(X, y, test_size=0.2)`, it returns Pandas Series `X_train` and `X_test` with `(192, )` and `(49, )` dimensions. As mentioned in the previous answers, sklearn expect matrices of shape `[n_samples,n_features]` as the `X_train`, `X_test` data. You can simply convert the Pandas ...
49,514,684
I'm relatively new to using sklearn and python for data analysis and am trying to run some linear regression on a dataset that I loaded from a `.csv` file. I have loaded my data into `train_test_split` without any issues, but when I try to fit my training data I receive an error `ValueError: Expected 2D array, got 1D ...
2018/03/27
[ "https://Stackoverflow.com/questions/49514684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1061892/" ]
You just need to adjust your last columns to ``` lm = linear_model.LinearRegression() model = lm.fit(X_train.values.reshape(-1,1), y_train) ``` and the model will fit. The reason for this is that the linear model from sklearn expects > > X : numpy array or sparse matrix of shape [n\_samples,n\_features] > > > ...
Once you load the data into `train_test_split(X, y, test_size=0.2)`, it returns Pandas Series `X_train` and `X_test` with `(192, )` and `(49, )` dimensions. As mentioned in the previous answers, sklearn expect matrices of shape `[n_samples,n_features]` as the `X_train`, `X_test` data. You can simply convert the Pandas ...
72,484,522
I am making a little math game, similar to [zeta mac](https://arithmetic.zetamac.com/game?key=a7220a92). Everything seems to be working well. Ideally I would like this console output to erase incorrect answers entered by the user, without reprinting the math problem again for them to solve. Is something like this possi...
2022/06/03
[ "https://Stackoverflow.com/questions/72484522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19244670/" ]
Keep the duration in a variable and decrease the duration in every loop ``` def blink_green2(): red1.on() sleep_duration = 0.5 for i in range(5): green2.toggle() time.sleep(sleep_duration) green2.toggle() time.sleep(sleep_duration) sleep_duration -= 0.01 ```
Gradually increasing the speed of blinking means that you need to decrease the sleep duration between the blinking. So in the for loop you need to decrease the value of i. so something like this. ``` def blink_green2(): red1.on() for i in range(0,0.5,0.1): green2.toggle() time.sleep(0.5-i) ```
72,484,522
I am making a little math game, similar to [zeta mac](https://arithmetic.zetamac.com/game?key=a7220a92). Everything seems to be working well. Ideally I would like this console output to erase incorrect answers entered by the user, without reprinting the math problem again for them to solve. Is something like this possi...
2022/06/03
[ "https://Stackoverflow.com/questions/72484522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19244670/" ]
Keep the duration in a variable and decrease the duration in every loop ``` def blink_green2(): red1.on() sleep_duration = 0.5 for i in range(5): green2.toggle() time.sleep(sleep_duration) green2.toggle() time.sleep(sleep_duration) sleep_duration -= 0.01 ```
If you want the led to blink faster, you could decrease the amount of time the task sleeps. As the loop increases, the value of **i** increases. Try this: ```py def blink_green2(): red1.on() for i in range(5): green2.toggle() time.sleep(0.5 - (i / 25)) green2.toggle() time.sleep(0.5 / (...
72,484,522
I am making a little math game, similar to [zeta mac](https://arithmetic.zetamac.com/game?key=a7220a92). Everything seems to be working well. Ideally I would like this console output to erase incorrect answers entered by the user, without reprinting the math problem again for them to solve. Is something like this possi...
2022/06/03
[ "https://Stackoverflow.com/questions/72484522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19244670/" ]
Keep the duration in a variable and decrease the duration in every loop ``` def blink_green2(): red1.on() sleep_duration = 0.5 for i in range(5): green2.toggle() time.sleep(sleep_duration) green2.toggle() time.sleep(sleep_duration) sleep_duration -= 0.01 ```
try this ```py def blink_green(): green2.on() delay = 0.5 for i in range(5): green2.toggle() time.sleep(delay) green2.toggle() time.sleep(delay) delay -= .1 while True: blink_green() ``` > > at an increasing rate > > > it should start with a .5s delay and speed up ...
72,565,884
I have a following code that handle with sockets in Python: ```py import socket HOST = "127.0.0.1" PORT = 4999 TIMEOUT = 1 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST, PORT)) # s.listen() conn, addr = s.accept() conn.settimeout(TIMEOUT) with conn: prin...
2022/06/09
[ "https://Stackoverflow.com/questions/72565884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14667788/" ]
You don't need threads to handle serial connections, and your example "with threads" didn't use threads at all. It just created (and didn't save) a `threading.Lock` object. Use a `while` loop to accept the next connection: ```py import socket HOST = '' PORT = 4999 with socket.socket() as s: s.bind((HOST, PORT...
Something like this: Main thread receives data and append to list. Thread monitors list for data to do whatever. ``` def receive_tcp_packets(self): server_socket.bind(socket.AF_INET, socket.SOCK_STREAM) as server_socket: server_socket.listen() server_conn, address = server_socket.accept() # Wait for ...
65,047,449
I am trying to fetch data from a MySQL database using python connector. I want to fetch records matching the `ID`. The ID has an integer data type. This is the code: ```py custID = int(input("Customer ID: ")) executeStr = "SELECT * FROM testrec WHERE ID=%d" cursor.execute(executeStr, custID) custData = cursor.fetchal...
2020/11/28
[ "https://Stackoverflow.com/questions/65047449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14631135/" ]
The string only accepts %s or %(name)s , not %d. ``` executeStr = "SELECT * FROM testrec WHERE ID=%s" ``` and the variables are supposed to be in a tuple, although that varies by implementation depending on what version you are using, you might need to use: ``` cursor.execute(executeStr, (custID,)) ``` More infor...
Your should try %s not %d. This is because your data type of MYSQL may be int but the parameter you should pass to cursor must be string. Try this: ``` custID = int(input("Customer ID: ")) executeStr = 'SELECT * FROM testrec WHERE ID=%s'%(custID,) cursor.execute(executeStr, custID) custData = cursor.fetchall() if ...
65,047,449
I am trying to fetch data from a MySQL database using python connector. I want to fetch records matching the `ID`. The ID has an integer data type. This is the code: ```py custID = int(input("Customer ID: ")) executeStr = "SELECT * FROM testrec WHERE ID=%d" cursor.execute(executeStr, custID) custData = cursor.fetchal...
2020/11/28
[ "https://Stackoverflow.com/questions/65047449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14631135/" ]
The string only accepts %s or %(name)s , not %d. ``` executeStr = "SELECT * FROM testrec WHERE ID=%s" ``` and the variables are supposed to be in a tuple, although that varies by implementation depending on what version you are using, you might need to use: ``` cursor.execute(executeStr, (custID,)) ``` More infor...
Instead of this: ```sql custID = int(input("Customer ID: ")) executeStr = "SELECT * FROM testrec WHERE ID=%d" ``` You should write: ```sql custID = int(input("Customer ID: ")) executeStr = "SELECT * FROM testrec WHERE ID='"+custID+"';" ```
50,807,953
I am trying to write a code that finds repeated characters in a word using python 3.x. For instance, ``` "abcde" -> 0 # no characters repeats more than once "aabbcde" -> 2 # 'a' and 'b' "aabBcde" -> 2 # 'a' occurs twice and 'b' twice (bandB) "indivisibility" -> 1 # 'i' occurs six times ``` Here is the code I have...
2018/06/12
[ "https://Stackoverflow.com/questions/50807953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7852656/" ]
I don't understand what your code is supposed to do: you never put anything in `final` and you `return` immediately. The below solution keeps two `set`s as it iterates over the input. One is every character we've seen, the other is every character that occurs more than once. We use `set`s because they have very fast ...
> > I want to grow in my python skills so I want to understand what's going wrong with it and why. > > > Any ideas? > > > Well, for one thing, since you never actually put anything in "final" you will never have a case for which "i" is in "final"... Here's a function that will do what you want: ``` def do_stuf...
50,721,735
I have both the version of python.I have also installed jupyter notebook individually and when i open the jupyter notebook and go to new section it is showing python 2 I want to use python3 for newer packages.So how can we upgrade the python version.
2018/06/06
[ "https://Stackoverflow.com/questions/50721735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8722059/" ]
Creating an instance that uses a service account requires you have the compute.instances.setServiceAccount permission on that service account. To make this work, grant the [iam.serviceAccountUser](https://cloud.google.com/compute/docs/access/iam#the_serviceaccountuser_role) role to your service account (either on the e...
### Find out who you are first * if you are using Web UI: what **email** address did you use to login? * if you are using local `gcloud` or `terraform`: find the json file that contains your credentials for gcloud (often named similarly to `myproject*.json`) and see if it contains the **email**: `grep client_email myp...
50,721,735
I have both the version of python.I have also installed jupyter notebook individually and when i open the jupyter notebook and go to new section it is showing python 2 I want to use python3 for newer packages.So how can we upgrade the python version.
2018/06/06
[ "https://Stackoverflow.com/questions/50721735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8722059/" ]
Creating an instance that uses a service account requires you have the compute.instances.setServiceAccount permission on that service account. To make this work, grant the [iam.serviceAccountUser](https://cloud.google.com/compute/docs/access/iam#the_serviceaccountuser_role) role to your service account (either on the e...
Make sure that NAME\_OF\_SERVICE\_ACCOUNT is service account from current project. If you change project ID, and don't change NAME\_OF\_SERVICE\_ACCOUNT, then you will encounter this error. This can be checked on Google Console -> IAM & Admin -> IAM. Then look for service name [email protected]...
50,721,735
I have both the version of python.I have also installed jupyter notebook individually and when i open the jupyter notebook and go to new section it is showing python 2 I want to use python3 for newer packages.So how can we upgrade the python version.
2018/06/06
[ "https://Stackoverflow.com/questions/50721735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8722059/" ]
### Find out who you are first * if you are using Web UI: what **email** address did you use to login? * if you are using local `gcloud` or `terraform`: find the json file that contains your credentials for gcloud (often named similarly to `myproject*.json`) and see if it contains the **email**: `grep client_email myp...
Make sure that NAME\_OF\_SERVICE\_ACCOUNT is service account from current project. If you change project ID, and don't change NAME\_OF\_SERVICE\_ACCOUNT, then you will encounter this error. This can be checked on Google Console -> IAM & Admin -> IAM. Then look for service name [email protected]...
22,883,337
Hey all am new to python programming and i have noticed some code which is really confusing me. ``` import collectors s = 'mississippi' d = collectors.defaultdict(int) for k in s: d[k] += 1 d.items() ``` The thing i need to know is the use of d[k] here ..I know k is the value in the string s.But i didnt unders...
2014/04/05
[ "https://Stackoverflow.com/questions/22883337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3501595/" ]
Dictionaries in Python are "mapping" types. (This applies to both regular `dict` dictionaries and the more specialized variations like `defaultdict`.) A mapping takes a key and "maps" it to a value. The syntax `d[k]` is used to look up the key `k` in the dictionary `d`. Depending on where it appears in your code, it ca...
Here you go ``` d[key] Return the item of d with key key. Raises a KeyError if key is not in the map. ``` Straigth from the [python docs](https://docs.python.org/2/library/stdtypes.html), under mapping types. Go to <https://docs.python.org/> and bookmark it. It will become your best friend.
45,471,477
I need the sacred package for a new code base I downloaded. It requires sacred. <https://pypi.python.org/pypi/sacred> conda install sacred fails with PackageNotFoundError: Package missing in current osx-64 channels: - sacred The instruction on the package site only explains how to install with pip. What do you do...
2017/08/02
[ "https://Stackoverflow.com/questions/45471477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1058511/" ]
That package is not available as a conda package at all. You can search for packages on anaconda.org: <https://anaconda.org/search?q=sacred> You can see the type of package in the 4th column. Other Python packages may be available as conda packages, for instance, NumPy: <https://anaconda.org/search?q=numpy> As you can...
It happens some issue to me before. If your system default Python environment is Conda, then you could download those files from <https://pypi.python.org/pypi/sacred#downloads> and manually install by ``` pip install C:/Destop/some-file.whl ```
60,699,328
I'm getting the following error when trying to install pychalk: ``` pip install pychalk --user ``` ``` FileNotFoundError: [Errno 2] No such file or directory: 'c:\\users\\jokzc\\appdata\\roaming\\python\\python38\\site-packages\\MarkupSafe-1.1.1.dist-info\\METADATA' ```
2020/03/16
[ "https://Stackoverflow.com/questions/60699328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12868860/" ]
You are using Python 3.8. > > ...python\\python38\\site-packages\... > > > The [last release for pychalk](https://pypi.org/project/pychalk/#history) was 2018, before the [releases for Python3.8](https://www.python.org/dev/peps/pep-0569/#schedule) came out. The package is probably not updated yet to support Py...
you just need to delete the OpenCV-python folder from the(path=**C:\Users\rahul\AppData\Local\Programs\Python\Python37\Lib\site-packages\opencv\_python-3.4.2.17.dist-info**) and then again you have to install that library you can see the picture below. here I have attached two pics in which first is showing error messa...