log_score
int64
-1
11
ViewCount
int64
8
6.81M
A_Id
int64
1.99k
72.5M
Available Count
int64
1
18
Question
stringlengths
15
29k
AnswerCount
int64
1
51
Q_Score
int64
0
6.79k
is_accepted
bool
2 classes
Tags
stringlengths
6
94
CreationDate
stringlengths
23
23
Q_Id
int64
1.98k
70M
Title
stringlengths
11
150
Answer
stringlengths
6
11.6k
Score
float64
-1
1.2
Users Score
int64
-36
1.15k
0
33
69,350,402
1
I need to run scons with --enable-virtualenv argument to make the third party python scripts called in SConstruct to work. Would like to know if I can achieve the same result by add some config in SConstruct instead of using command line argument?
1
0
false
python,scons
2021-09-27T00:08:00.000
69,339,908
How to enable virtualenv inside SConstruct?
Most likely you don't actually need to use --enable-virtualenv. Assuming you run them via: scriptname arguments You can just include the full path to that script /home/user/my_virtualenv/bin/scriptname arguments Or if you use python to run it via: python scriptname arguments You can run it as: /home/user/my_virtualenv/bin/python scriptname arguments Or if it's none of these, please explain why any of the above aren't working?
0
0
1
42
69,342,681
1
I want to use the exact filename of a json file for some other task which has a path name like: folder1/folder2/txt.json. I just want to retrieve txt.json name using some attribute of boto3 but I am not able to find any such attribute. This can be done easily by split method in python but I want to know if this can be done using boto3 as well while listing the objects?
1
0
false
python,amazon-s3,boto3
2021-09-27T07:13:00.000
69,342,549
To get the exact filename without the prefix of parent folders while using client Boto3 SDK
This can be done easily by split method in python Yes, that's the correct way of doing this. S3 API just returned the entire key of your object, which is "folder1/folder2/txt.json". Its up to you to process it the way you want.
0.197375
1
0
55
69,844,589
1
From what I understand python -m zipapp myapp creates a .pyz file of the directory named myapp. How do i create a .pyz of the current folder in which my working directory is set. I tried python -m zipapp . which doesnt work. What would be the exact argument for packaging of the working directory? Same doubt for the following: If I do pip install -r requirements.txt --target <directory>, how do i mention current working directory in <directory>
1
0
false
python,python-3.x,command-line-arguments,zipapp
2021-09-27T14:02:00.000
69,348,031
How to make a zipapp of current directory?
Thinking about the same later, I have reached the conclusion that being able to make the zip file of the directory the terminal is set to doesn't make much sense due to which I don't think there's an solution to this question. Hence I believe zipapp can only take place for a given folder in the directory and not the directory the terminal is set in.
0
0
1
472
69,392,884
1
I have a large number of fits files that I'm unable to open becuase of a missing SIMPLE keyword. When I try to open them using astropy's fits.open() it gives the following error: OSError: No SIMPLE card found, this file does not appear to be a valid FITS file I tried adding the ignore_missing_simple=True option to fits.open(), but this still gives an error: OSError: Empty or corrupt FITS file I'm not sure what to do here. My first thought was to edit the fits header to add a SIMPLE keyword, but if I can't open the file I don't know how to deal with this. I'm wondering if theres more going on than just the missing SIMPLE keyword given the second error. If it matters, I've downloaded the fits files, I did not generate them myself.
2
3
false
python,astropy,fits
2021-09-27T16:04:00.000
69,349,808
Opening fits files with no SIMPLE keyword in python
We traced the problem to astropy.io.fits version 4.3 Files generated with version 4.2 can be read with 4.0 or 4.2 but this error pops up with 4.3.1. You could try again after downgrading astropy.io.fits.
0.099668
1
0
511
71,015,622
1
I am working on aws lambda function, i install the package but i got error Unable to import module 'lambda_function': cannot import name 'cygrpc' from 'grpc._cython' (/var/task/grpc/_cython/init.py) How to solve this type of error?
2
0
false
python,amazon-web-services,aws-lambda
2021-09-28T06:17:00.000
69,356,666
"Unable to import module 'lambda_function': cannot import name 'cygrpc' from 'grpc._cython' (/var/task/grpc/_cython/__init__.py)"
In addition to an answer marked correct I wanted to mention that for libraries using C-extensions is important that the layer was built on the same type of system as it runs in lambda. For example, if you're trying to build the layer including grpc on MacOS most likely it won't work since lambda is running on Linux. To make the layer working you have to build it in a Linux system (for example, on the virtual machine or in Docker)
0
0
0
43
69,357,756
1
I have multiple pipelines with scripts defined on my azure devops. I would like to be able to run them from my local machine using python. Is this possible? If yes, how to achieve it? Regards, Maciej
1
0
false
python,azure-devops,azure-pipelines
2021-09-28T07:23:00.000
69,357,387
Is there a way to run azure-devops pipeline from python?
You can't run them in this way that you will take YAML code and put it python or actually any language and run it locally. You need to build agent to run your pipeline. So you can create a pool, install agent on you local machine, change your pipeline to use this pool.
0
0
1
112
69,446,214
1
i'm looking for a framework that is able to solve the following Data Science issue: I have several Teachers that can work for X amount of hours a week and have several subject that they can teach. Teacher 1: Math Teacher 2: Math + English Teacher 3: Sports + Art + English Teacher 4: Math + Art Teacher 5: Sports + Math + English In a school, every subject needs a specific amount of hours per week. Some more than others Math: 12 hours English: 8 hours Art: 4 hours Sport: 2 hours Lets say one teacher can do 2-3 hours just so you get my point^^ The Solution im looking for is a Framework or Algoritm that is filled (trained) with the data and then is able to distribute the teachers so all the subjects are capped or at least as close as possible. That means maybe Teacher 2 needs to teach only Math and Teacher 5 needs to teach 50% Sport and 50% English or 30% Math / 40% Sport / 30% English. Someone mentioned Prolog but im not sure if it can handle this kind of problem? Maybe im wrong? Is there something that is fitting for my problem or am i destined to code that algorithm from scratch on my own? Thanks in advance.
2
0
false
javascript,python,prolog,data-science,data-science-experience
2021-09-28T07:57:00.000
69,357,856
LF Framework to solve Data Science Issue
The first step seems to be to translate a research problem (or a series of problem statements) into a precise form. Problem Characterization/Problem Conceptualization seems to be a technique for resolving that issue. Once the approach has been conceptualised, a technique must be identified for each of the sub-models and submodules. Breaking down the high problem statement into smaller problems is called problem conceptualizing. For every subproblem, a technique must be identified, and the methodology must be determined by the assumptions that have been stated previously. Realization of a Solution: Determines whether the assumptions are reasonable or whether the solutions meet his needs. This can be compared to a flowchart that he has been creating with these subproblems, and also in general, it is attempting to reach a granularity level where he would determine the issue class. As a result, these issues can be classified as being either function optimization or categorization issues.
0.099668
1
0
189
69,362,103
1
I tried to run the below command on my virtual env window 10. pip freeze > requirements.txt, but I get an access denied response I also tried this pip freeze > requirements.txt --user but I got the same response. what could be wrong and how can I fix this?
1
0
false
python,heroku,anaconda
2021-09-28T12:44:00.000
69,362,000
Access is denied: pip freeze > requirements.txt
perhaps you don't have the write permissions. Try to delete "requirements.txt" file (if ones already exists) and run that command "pip freeze > requirements.txt" again. Also check your permission via "chown"
0
0
2
98
69,369,524
1
I have a Python 3.6 project that I want to migrate to Python 3.8. I also have a requirements.txt file generated with pip freeze, which is used by the Python 3.6 project. Is there a way to know if the packages listed in requirements.txt, with their own specific pinned version, support/are compatible with Python 3.8? I could imagine some ways to do that, like check the packages classifiers or look at tox.ini and so on, but the requirements file has ~300 packages listed and doing that manually would be cumbersome at best.
1
0
true
python,requirements.txt,versionupgrade
2021-09-28T22:57:00.000
69,369,268
Python upgrade and requirements compatibility
If you do a pip install -r requirements.txt under the new version of Python (in a venv), it'll tell you if it can't find that particular version of a package for it If there are several missing, it'll be a bit annoying, because it'll only tell you one at a time, but hopefully there won't be too many Not sure if there's an official documented procedure in the docs, but this should give you a quick idea, especially on the happy path where it just works
1.2
1
1
74
69,372,785
1
When I want a user in Python3, from terminal sudo su python3 >>> import getpass >>>getpass.getuser() 'root' how can I get the normal username?
2
0
false
python,ubuntu
2021-09-29T08:12:00.000
69,372,729
python get normal username from the root user?
If you are running the script interactively, you should be using sudo to run it and os.getlogin() will give the correct user.
0.099668
1
0
159
69,373,141
1
I have a Python code running on Spyder on our server which needs to run constantly. However, from time to time our server breaks and it is restarted. Unfortunately, my code stops running as well and I need to restart Spyder and the code manually when opening it the next day. Is there any way to restart the code automatically when the server is restarted? Thank you a lot!
2
0
false
python,python-3.x,server,spyder,boot
2021-09-29T08:32:00.000
69,372,980
Restart Python Code after restarting the server
You can add as a crontab rule what you want to run after reboot. You can use this line in crontab by using crontab -e command, if you use server running on Linux platform. @reboot <your_python_file_path>
0
0
0
84
69,395,290
1
Im using python 3.7 Im new to python (my main dev experience comes from javascript). I understand there is a Pipfile who specify the packages Im using directly . Additionally, there is a Pipfile.lock which specifies exact versions of direct and indirect dependencies (like yarn\package.lock in js ). requirements.txt looks like its doing the exact same thing . Which ones should I track ? Thanks
1
0
false
python,python-3.x,pipenv,pipenv-install
2021-09-30T15:46:00.000
69,395,246
should I track (version control - e.g git, github ) requirements.txt?
Pipfile (and Pipfile.lock) are specific to pipenv, which is a relatively new tool. Whether you maintain requirements.txt depends on whether you want people using your repository to be able to use pip directly, rather than using pipenv themselves In general, you should keep both Pipfile and Pipfile.lock under source control. Pipfile.lock is what specifies exactly what packages should be installed in the pipenv-managed virtual environment for reproducible builds. Pipfile is mostly a convenience for generating Pipfile.lock.
0
0
3
7,196
69,396,372
1
ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'C:\Users\Sampath\anaconda3\Lib\site-packages\~5py\defs.cp38-win_amd64.pyd' Consider using the --user option or check the permissions. I tried pip install mediapipe
1
4
true
python,mediapipe
2021-09-30T17:10:00.000
69,396,320
Could not install packages due to an EnvironmentError: [WinError 5] Access is denied
EnvironmentError: Access is denied errors usually stem from one of two reasons: You do not have the proper permissions to install these files, and you should try running the same commands in an Administrator Command Prompt. 90% of the time, this should solve the problem. If the first doesn't work, then the problem is usually from an external program accessing a file, and you (or the installation script) are trying to delete that file (you cannot delete a file that is opened by another program). Try to restart your computer, so that whatever process is using that file will be shut down. Then, try the command again.
1.2
3
0
68
69,406,973
1
I have try to run python with sublime text and the following error message appear on my screen when I run the program. Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases. [Finished in 277ms]. Please advise how to fix the problem.
1
0
false
python,sublimetext3
2021-10-01T13:36:00.000
69,406,816
Unable to run python with sublime text
Check python is in path Them try ctrl + B on sublime text Or you can start python file via python app in terminal python path_to_file.py
0
0
3
1,456
69,431,862
2
I am getting the following error while trying to import newly installed packages from pip: Import "<package>" could not be resolved Pylance(reportMissingImports) After I restart VS code, Pylance seems to then be able to recognise the package. Is there any fix to this as it is very annoying!
2
2
false
python,visual-studio-code,pip,pylance
2021-10-01T13:51:00.000
69,407,034
Pylance does not recognise newly installed pip packages
This question will happen when Pylance doesn't detect the module immediately. You may Reload Window from Command Palette to refresh the current project.
1
8
-1
1,456
71,278,218
2
I am getting the following error while trying to import newly installed packages from pip: Import "<package>" could not be resolved Pylance(reportMissingImports) After I restart VS code, Pylance seems to then be able to recognise the package. Is there any fix to this as it is very annoying!
2
2
false
python,visual-studio-code,pip,pylance
2021-10-01T13:51:00.000
69,407,034
Pylance does not recognise newly installed pip packages
If you are using VS Code, open the command pallet and run "Python: Restart Language Server"
-0.099668
-1
0
96
69,417,968
1
What is the best way to save random user tool settings in a nuke script file? I searched around online a fair bit and found nothing regarding this topic which I found hard to believe. At the end of the day my goal is to save some random tool data on in the file and additionally save some other data specifically on a few nodes in the graph. I was unable to find info on either.
1
0
false
python,nuke
2021-10-01T15:45:00.000
69,408,647
Nuke Python save tool settings in nuke script file
Save it on the root! Create a custom knob of any type, set it to "hidden" and store it on the Root of the script: nuke.Root() The Root is just a fancy knob, so most any command that works on a node can also work on the Root.
0
0
1
211
69,422,313
1
When cancelling a solution search early, which is not based on a specified rel. MIP gap limit but e.g. via a time limit, is it possible to display the relative MIP gap of the best feasible solution that was found by the solver?
1
1
true
python,or-tools,mixed-integer-programming,scip
2021-10-01T17:46:00.000
69,410,076
How to get relative MIP gap in Google OR-Tools and Python via SCIP solver?
Unfortunately there is no direct API as the definition of relative MIP gap varies across solvers. You can always pick one formula and recompute it using the two methods on the objective: MPObjective.Value() and MPObjective.BestBound().
1.2
0
0
73
69,506,898
2
I have recently downloaded some models for blender but when I unzipped it the file was in .py format I want to add them to my project but I cant I tried "open in" method but no results..... can anyone tell me how to fix it
2
0
false
python,model,blender
2021-10-02T02:16:00.000
69,413,494
how can I convert .py file to .blend
Please specify what the content of the .py file is. A .py file is a python script, and you can't just "convert" it in a blender file. They are two different things. It might be the case that the .py file is just a text file (saved as a .py file) that contains the coordinates of a mesh. In this case, just change .py in .obj and import it in blender.
0
0
0
73
69,413,507
2
I have recently downloaded some models for blender but when I unzipped it the file was in .py format I want to add them to my project but I cant I tried "open in" method but no results..... can anyone tell me how to fix it
2
0
false
python,model,blender
2021-10-02T02:16:00.000
69,413,494
how can I convert .py file to .blend
You can simply change its format from .py to .blend you can do this with help of notepad. open .py file in notepad and save as .blend format.
0
0
2
324
69,418,546
1
I successfully installed the module geocoder: Requirement already satisfied: chardet<5,>=3.0.2 in c:\users\myname\appdata\roaming\python\python39\site-packages (from requests->geocoder) (4.0.0) Installing collected packages: ratelim, geocoder Successfully installed geocoder-1.38.1 ratelim-0.1.6 When I try to create a Python file that includes import geocoder, I get the error Import "geocoder" could not be resolved. The relevant path is included in sys.path: C:\Users\myname\Downloads C:\Users\myname\AppData\Local\Programs\Python\Python39\python39.zip C:\Users\myname\AppData\Local\Programs\Python\Python39\DLLs C:\Users\myname\AppData\Local\Programs\Python\Python39\lib C:\Users\myname\AppData\Local\Programs\Python\Python39 C:\Users\myname\AppData\Roaming\Python\Python39\site-packages C:\Users\myname\AppData\Roaming\Python\Python39\site-packages\win32 C:\Users\myname\AppData\Roaming\Python\Python39\site-packages\win32\lib C:\Users\myname\AppData\Roaming\Python\Python39\site-packages\Pythonwin C:\Users\myname\AppData\Local\Programs\Python\Python39\lib\site-packages C:\Users\myname\AppData\Local\Programs\Python\Python39\lib\site-packages\win32 C:\Users\myname\AppData\Local\Programs\Python\Python39\lib\site-packages\win32\lib C:\Users\myname\AppData\Local\Programs\Python\Python39\lib\site-packages\Pythonwin Why isn't Python able to resolve this module? Thanks
1
1
true
python,python-3.x
2021-10-02T16:47:00.000
69,418,403
Python can't find installed module
Either geocoder is installed to other than Python3.9 version installation (e.g. python 3.7) or geocoder is not in the path of your python module. Try to install the library using specific Python pip package manager (e.g. pip3.9) and run the module you develop using specific Python version (e.g. Python3.9)
1.2
1
0
205
69,419,127
1
I'm trying to fix leaks in a ctypes-based Python binding over a C library. I'm confused as to the behavior of memory management of strings and other pointers when working with ctypes. There are, to my knowledge, 3 cases I need to solve, basically: A) Creating memory in C and returning a c_char_p as the result of the function to the Python. B) Creating a string in the Python, and passing it as a char const* parameter of a C function, and not freeing it in the C: this is the only one I've solved confidently: I can just do my_str.encode("utf-8") into a c_char_p, and the Python Alloc/GC handles both the allocation and deallocation. C) Creating memory in Python, and storing it in the C (for example as a char* field within a struct), to be deallocated later (with a function from the C library). My questions: A) is the c_char_p thus created a second pointer ? If so, what happens to the pointer allocated by the C ? how do we free the pointer returned from the C ? is there a difference of behavior between how c_void_p and c_char_p are handled as restype by the GC ? C) What is the correct way to "give ownership" of a memory pointer allocated in Python to the C ? .encode() clearly makes a Python object that's GC'ed. is a string created by create_string_buffer also Python-GC'ed ?
2
0
false
python,c,memory-management,memory-leaks,ctypes
2021-10-02T18:25:00.000
69,419,126
Memory management and removal of leaks, in C and Python with ctypes, using the example of strings
This is an adaptation of the exchange I had on the Python discord server with someone who answered the questions: is the c_char_p thus created a second pointer ? If so, what happens to the pointer allocated by the C ? Yes, it is. The c_char_p is a PyObject* pointer that lives on the heap, and it stores the original C char* pointer inside it. how do we free the pointer returned from the C ? Pass the c_char_p to free() using ctypes is there a difference of behavior between how c_void_p and c_char_p are handled as restype by the GC ? No, in both cases, when the c_void_p or c_char_p is garbage collected, it does nothing, ie, it does not free the original C object that was pointed to. What is the correct way to "give ownership" of a memory pointer allocated in Python to the C ? That's not normally something you'd do - memory created by Python is usually freed by Python, memory created by C is usually freed by C. If you need to pass something from one domain to the other, it's best to copy it. It's possible to make the C side keep a Python reference to the Python object by using the Python C API, but that's probably not the best idea. is a string created by create_string_buffer also Python-GC'ed ? In this case, when the Python object is GC'd, it also frees the C memory. A c_char_p knows whether it owns the memory that it points to or doesn't, and when it's GC'd it frees the C memory if it owns it. ======== Since my (I = asker) goal is to have as few (no) reference to ctypes types for the Python end-user, given the answers above, I would do the following: when I malloc a char* in the C in a function char* do_c_func(), I return it as a c_char_p restype in Python. In my Python, I have a wrapper function do_py_func() that calls do_c_func(), receives this c_char_p called my_c_char_p, and stores its contents in a Python string, through some sort of s = str(my_c_char_p). I then call ctypes.free(my_c_char_p): this frees the malloced char*, and the end of the function decrementing the last reference counter, this eventually garbage collects my_c_char_p. I create a conversion function python_str_to_c_str(py_str) which takes a normal python string, and returns stdc.strdup(py_str.encode('utf-8')) (with stdc.strdup.restype = c_char_p), thereby providing a new char* to the C (which Python will recognize as having been created in the C). I use this conversion function anywhere I need to pass a string from the Python to the C. This makes it so the buffer created by my_string.encode('utf-8')), and the c_char_p returned by stdc.strdup, are both garbage-collected by the Python, but the char* itself is not.
0
0
0
43
72,133,283
1
I have a set of commands, each from Juniper & Aruba switches, that I would like to automatically convert. Is there a way to use a string of Juniper commands and have them output a string of Aruba commands? If so, how would I approach this using Python? Would I use "if else", python dictionary commands, or some other syntax? For example: I have just come up with this script: def Juniper(sets): print ('host-name', set1) print ('console idle-timeout 600\n' 'console idle-timeout serial-usb 600\n' 'aruba-central disable\n 'igmp lookup-mode ip\n' 'console idle-timeout serial-usb 600\n') print ("logging (system1) oobm") #I AM TRYING TO ADD THE INPUT OF system1 IN BETWEEN LIKE THIS ^ AS SHOWN ABOVE set1= input('Enter hostname with quotations:\n') system1 = input('Enter system log IP address:') Juniper(set1) Please let me know how to add an input in between two strings or words
1
0
false
python,automation,juniper,aruba
2021-10-03T01:01:00.000
69,421,321
Juniper to Aruba Commands using Python
I would approach simply using show command with display json on juniper side and than use a jinja2 template to build your Aruba config using which dynamic data you want from juniper output and yes you can do all in python from extracting data from device till the convertion. Extracting data from device you can use scrapli nornir and than use the result as data for render with jinja template.
0
0
0
46
69,423,101
1
newRow = ["some_data", "some_data", "=MULTIPLY(A1;BA)"] When I'm trying this, in my google sheet, the cell in filled by : '=MULTIPLY(O33;M33) as a string. How can I make my equation usable ?
1
2
false
python,google-sheets,google-sheets-formula
2021-10-03T03:14:00.000
69,421,786
Insert equation in google sheet using python and the google sheet API
Remove the "" in your code will do the trick
0
0
2
94
69,424,706
1
I am starting a python project that needs Python 3.6 and on my computer I have only installed Python 3.9(which is added to PATH). When I am installing Python 3.6, should I add it to PATH because Python 3.9 is already added to PATH? If yes, what can I do to specify what Python version I want to use? When installing a package, how can I specify that I want to use Python 3.6 to install this package? How can I change my command prompt to use Python 3.6 instead of Python 3.9?
1
0
true
python,pip,path
2021-10-03T11:54:00.000
69,424,602
How to use a different Python version for a pipenv project?
When builiding the enviroment using pipenv you can specify the version you want to use for example: pipenv --python 3.6 on some cases a direct path to the python is needed but an appriprate message will show in that case.
1.2
1
1
186
69,435,458
1
Real quick question, what is the difference between line.strip("\n") and line.rstrip(os.linesep)? Especially, when using them in the Fasta file and other bioinformatics fields.
1
1
false
python,bioinformatics,biopython
2021-10-04T11:44:00.000
69,435,439
Difference detween line.rstrip("\n") and line.rstrip(os.linesep)?
line.strip("\n") removes the new-line character for UNIX and UNIX-like OSs. On the other side, line.strip(os.linesep) would automatically change to the correct new-line character for your current operation system (Mac OS, Linux, Windows, etc)
0.197375
1
0
79
69,435,736
2
I'm trying to run a python shell file, like the one in IDLE, directly inside vscode so that I can run single lines/blocks of code interactively. Is this possible, and if so, how?
3
0
false
python,shell,visual-studio-code
2021-10-04T12:05:00.000
69,435,712
Is it possible to enter the Python shell in vscode?
Open the terminal run new terminal, and if python is added to your path, write python in the shell and enter and it opens the python shell.
0
0
0
79
69,435,754
2
I'm trying to run a python shell file, like the one in IDLE, directly inside vscode so that I can run single lines/blocks of code interactively. Is this possible, and if so, how?
3
0
false
python,shell,visual-studio-code
2021-10-04T12:05:00.000
69,435,712
Is it possible to enter the Python shell in vscode?
To the original question, yes you can interact with the console and run python files as if you were running them from the command line. To your second query, VSCode has support for Jupyter notebook which is useful for running single lines of code. This may be what you're looking for
0
0
0
24
69,444,488
1
I have a search script that: opens a file finds a given item in a very small list closes the file Is such file juggling for a high number of iterations of this loop, not somehow detrimental to my hardware?
1
1
false
python,search
2021-10-04T14:07:00.000
69,437,418
Is accessing data from a file - with open() and close() Python functions - many times in quick succession not somehow bad for the hardware?
The kernel will cache files that are read repeatedly, so the disk won’t even be accessed after the first time (unless there is severe memory pressure). Not that reading from an SSD is what wears it out, and if the file were small you wouldn’t necessarily even seek on a spinning disk if there were no other disk activity.
0
0
1
26
69,451,797
1
I've installed pandas and numpy with anaconda 3.8.8. Is it possible to use this modules in the default Mac python version 3.8.2 or do I have to install them again? Best, Dawid
1
0
true
python,anaconda
2021-10-05T13:51:00.000
69,451,751
How to share modules installed on anaconda with different python versions?
Conda is a different installation than your system Python. So yes, you'll have to reinstall them (but that's simply pip install numpy pandas, though it'd be a great idea to use virtualenvs).
1.2
0
0
132
69,453,477
1
How to convert the data types between integer and float at Python? Please help… Can you show me an example?
3
0
false
python
2021-10-05T15:34:00.000
69,453,376
How to convert the data types between integer and float?
Using int() or float() changes the format of your data. In case it's not a simple fix like this, can you give a sample of your code?
0
0
1
400
69,459,117
1
I'm using pip 21.2.4 and python 3.9.7 I'm pretty sure I have pip installed since if I run pip --version in the terminal it gives me pip 21.2.4 from C:\Users\rohaan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pip (python 3.9) If I run pip install pygame in the terminal I get Requirement already satisfied: pygame in c:\users\rohaan\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (2.0.1) Despite the requirement being satisfied when I import pygame I get ModuleNotFoundError: No module named 'pygame' Does anybody know how to fix this?
2
2
true
python,visual-studio-code,import,pygame
2021-10-06T02:12:00.000
69,459,094
Can`t import pygame to VScode despite having it installed
This means you have multiple versions of python installed on your device, one has the module and the other tries to run the file, go to the control panel and check it out.
1.2
0
2
163
69,462,262
1
I have two Python environments in my Anaconda "base" and "image_analytics". Every time I close and start Anaconda Prompt, I can see "base" environment activated by default. I have to write "conda activate image_analytics" every time. I want image_analytics environment to get activated every time by default I restart Anaconda Prompt. Any solution? I am a beginner. Any help is appreciated.
1
2
false
python,anaconda,jupyter,conda
2021-10-06T06:35:00.000
69,460,905
In Anaconda/Python how to make my Virtual Environment as default environment when starting Anaconda Prompt?
It actually quite simple, because the anaconda prompt is just a shortcut to cmd with an added call to activate the base env, which can be modified to start other envs Locate the shortcut for anaconda prompt, either by going to Start Menu->Right Clik Anaconda Prompt->Open File Location or by navigating to the equivalent on your system of C:\Users\<Username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit) Open the properties of the shortcut: Right Click->Properties Modify the Target field. Original for me that activates the base env: %windir%\System32\cmd.exe "/K" C:\Users\<Username>\miniconda3\Scripts\activate.bat C:\Users\<Username>\miniconda3, which I can modify to e.g. start the py37 env: %windir%\System32\cmd.exe "/K" C:\Users\<Username>\miniconda3\Scripts\activate.bat C:\Users\<Username>\miniconda3\envs\py37. Note that I simply modified the last path in that line to point to an environment instead of base.
0.379949
2
0
31
69,464,183
1
Im having a project running on python2.7. The project is old but still its necessary to update the database when a request is received. But the update process takes time and ends up with a timeout. Is there anyway return JsonResponse/Httpresponse, before updating the database so that timeout doesn't occur. I know its not logical to do so, but its a temporary fix. Also, i cant use async since its python2
1
0
false
django,python-2.7,django-views
2021-10-06T08:55:00.000
69,462,657
Return JSONResponse before updating database in django, python2
Use multiprocessing or multithreading this will execute your task with another process and send HTTP response fastly to client-side
0
0
0
30
69,464,855
1
I wrote python code on windows at development stage, During my project I used many modules for example: pandas,numpy,...etc. I am trying to deploy this code in production (Linux), and those modules not installed on this machine. so I want to make my code portable with it’s drivers and utilities, modules which I used it. How can I do that?
1
0
false
python,linux
2021-10-06T11:19:00.000
69,464,752
How to make my python code portable with it’s drivers
1.Generate a requirements.txt file from your local project 2.Login to your linux server via ssh 3.Install the version of python you want on your linux server (it generaly contains a 2.7 version) 4.Create a specific folder for your project 5.In that folder, create a virtual environment using the Python that you have installed upload the requirements.txt in the folder and install it using pip install -r requirements.txt after activating the virtual environment.
0
0
0
731
69,469,306
1
I got this err: import pandas as pd ModuleNotFoundError: No module named 'pandas' My versions installed are: Python ver 3.9.7 pandas 1.3.3 pip 21.2.4 PyCharm 11.0.12 I can see pandas installed in pycharm, but when I am importing it I got that err. Any clue? Thank you
2
0
false
python,pandas,pip,pycharm
2021-10-06T16:17:00.000
69,469,229
Python : ModuleNotFoundError: No module named 'pandas'
Try to reinstall pandas package. type = pip install pandas wait for some time and then your panda package will get installed
0
0
0
218
69,475,417
1
I opened a series of files to edit them and my run button is greyed out. I can't figure out exactly why, but I think it has something to do with the "add configuration" prompt nest to the run button. I don't know how to add a configuration and don't want to mess up my editor. I have the newest version of the community version of PyCharm.
1
0
false
python,pycharm,config
2021-10-07T04:16:00.000
69,475,385
Adding a run configuration in PyCharm for a python project
Add Configuration is greyed out because maybe you haven't added python path to the project try adding it and you should be clear before posting questions maybe some code and pictures will help. Try this and let me know if this have solved your problem.
0
0
3
1,692
69,479,955
1
Started getting this error today on my Django project that uses Stimulus js. This started happening due to the recent Stimulus js 3.0.1 release. Adding an answer with the solution that worked.
1
0
true
python,django,stimulusjs
2021-10-07T09:51:00.000
69,479,061
Uncaught TypeError: Cannot read properties of undefined (reading 'start')
Faced same issue after stimulus release 3.0.1. we had the Stimulus js file included using the path https://unpkg.com/stimulus/dist/stimulus.umd.js. After version 3.0.1 release, stimulus stopped working saying Uncaught TypeError: Cannot read properties of undefined (reading 'start') in chrome and Uncaught TypeError: Stimulus.Application is undefined in Firefox, but both pointing to same code. Opening that path redirected to https://unpkg.com/stimulus@3.0.1/dist/stimulus.umd.js that had only 10 to 15 lines of code, probably some mistake in unpkg. Specifying older stimulus version in the path( and hence using version 3.0.0 of stimulus ), the error disappeared. Here is the url with previous version: https://unpkg.com/stimulus@3.0.0/dist/stimulus.umd.js.
1.2
3
2
79
69,482,938
1
I quite like the Spyder IDE's outline view of my Python code, and would like to save it as text to aid in documentation. I could not find a way to do this and wondered: Is their a way I am missing? Or is their a separate tool that can give a similar hierarchical outline of a Python source file? Thanks in advance :-)
1
1
true
python,spyder
2021-10-07T11:12:00.000
69,480,114
Spyder outline view of Python code: Save as text?
(Spyder maintainer here) Unfortunately, it is not possible to save our Outline tree view as text, sorry.
1.2
1
0
977
69,480,728
1
I got the error given below ,While launching the sysmon in Linux : "Traceback (most recent call last): File "/usr/local/bin/sysmon", line 5, in from sysmon.sysmon import main File "/usr/local/lib/python3.6/site-packages/sysmon/sysmon.py", line 1, in from PyQt5 import QtWidgets, uic ImportError: libGL.so.1: cannot open shared object file: No such file or directo ry" I have installed the following packages with the command "pip3 install sysmon --force" numpy -version 1.19.5, ,pip -version 21.2.4 ,PyQt5 -version 5.15.4 PyQt5-Qt5 -version 5.15.2 ,PyQt5-sip -version 12.9.0 ,pyqtgraph -versin 0.11.1 sysmon -version 1.0.1 Please anyone can help me to resolve the issue.
1
0
false
python
2021-10-07T11:26:00.000
69,480,301
ImportError: libGL.so.1: cannot open shared object file: No such file or directo ry while launching sysmon
i think you don't have ffmpeg installed because libGL.so.1 is part of ffmpeg for install ffmpeg you can use: Ubuntu: sudo apt install ffmpeg Arch Linux: sudo pacman -S ffmpeg and for other distros search in package manager of that distro you can find ffmpeg
0
0
-1
23
69,483,975
1
I am trying to make a scripted download/install of the latest version of python. For Golang I can use the following URL to determine the newest version of Golang. https://golang.org/VERSION?m=text and then download it. Is there a similar URL or some other way to get the latest version of Python3? I do not want to hardcode the version number... my script should simply install/update the Python3 installation in the target directory.
1
0
false
python-3.x
2021-10-07T15:31:00.000
69,483,895
Scripted Python Install for Latest Version
Hi you could use https://www.python.org/downloads/release/python-x and then enter the python Version you want without the dots. For Python 3.8.10 the link would look like this: https://www.python.org/downloads/release/python-3810/
-0.197375
-1
2
147
69,485,250
1
In Python, a string can have arbitrary bytes, via "\x??" escaping. These bytes don't necessarily have to map to a char in an encoding. For example, we can have "\xa0", even though 0xa0 isn't a good utf-8 char. However, if I have a byte array, such as b'\xa0', I can't append it to a string without decoding it. What if I want to just append literally, just like "\xa0"? How can I append a series of bytes to a string without decoding them at all, just like "\x" escape chars? Is there a "literal decoding" or "no decoding" option to decode()? If not, is there another way to do this?
1
0
true
python,character-encoding
2021-10-07T17:01:00.000
69,485,142
Python: How can I append literal bytes to a string with no decoding?
First, consider whether storing these in a string is truly the best for your usecase. Storing as bytes/bytesarray is usually the more idiomatic option. However, if you have considered this and still decided to proceed, then you should pass "latin1" as the encoding option to bytes.decode. This converts the bytes directly to the characters with the corresponding value.
1.2
1
4
4,144
69,496,505
1
While installing some libraries you may find the issue ModuleNotFoundError: No module named '_ctypes'
2
11
false
python,macos
2021-10-08T13:18:00.000
69,496,504
ModuleNotFoundError: No module named '_ctypes' Mac M1
Make sure you are running python 3.8.10 +
1
11
1
147
69,499,827
1
A python script that uses cv2 runs fine from command line once the virtual environment is activated ((venv) pi@raspberrypi:~/test $ python3 openCV_motion_detection_cam1.py ). But when run from normal command line (pi@raspberrypi:~/test $ python3 openCV_motion_detection_cam1.py ) , it outputs error - "No module named 'cv2'", which is already inside /home/pi/test/venv/lib/python3.7/site-packages.I am a newbie and expecting your comments to be 'Noob' friendly . Please help.
2
0
false
python
2021-10-08T17:27:00.000
69,499,673
Python script inside virtual env not running in command line
Virtual environments exist to isolate the modules needed for individual python programs from each other. When you installed cv2 you installed it within your currently active venv. When the venv is not active it's modules will not be available on. Simple solution is to run your program within the venv. You can tell that the module exists within a venv by the /venv/lib/python37/site-packages portion of the modules path.
0.099668
1
1
334
69,502,328
2
I'm learning to code with python 3.9, but the resources I'm using are referred to a previous build. In one of the exercises I'm supposed to use pythonw.exe to run a script in the background, however I don't have such file in my installation folder. After searching online, I have found that the file must have been automatically deleted by the antivirus during the install. So I uninstalled and reinstalled again while disabling the antivirus during the install (malwarebytes + win defender), but pythonw is still missing. At this point I don't know if there is another workaround or if there is an alternative to pythonw for version 3.9.. Anyone can help shed some light?
2
0
false
python,windows,python-3.9,pythonw
2021-10-08T22:19:00.000
69,502,251
pythonw.exe in python 3.9
pythonw.exe should be in the same directory as python.exe. For me (running Python 3.8) that is C:\Program Files\Python38. With a different install option, it probably would be in C:\Python38. (Yours would presumably have "Python39" where I have "Python38".) Did you get your Python installation file from python.org? It should include pythonw.exe; if you got your distribution from somewhere else, it may be tailored differently. The difference between python.exe and pythonw.exe is that pythonw.exe will avoid opening an extra window. If you don't care about that, go ahead and use python.exe. By the way, I have both MalwareBytes and Windows Defender installed, and neither of those have ever deleted pythonw.exe for me, so I doubt that's your issue.
0.099668
1
0
334
69,506,398
2
I'm learning to code with python 3.9, but the resources I'm using are referred to a previous build. In one of the exercises I'm supposed to use pythonw.exe to run a script in the background, however I don't have such file in my installation folder. After searching online, I have found that the file must have been automatically deleted by the antivirus during the install. So I uninstalled and reinstalled again while disabling the antivirus during the install (malwarebytes + win defender), but pythonw is still missing. At this point I don't know if there is another workaround or if there is an alternative to pythonw for version 3.9.. Anyone can help shed some light?
2
0
false
python,windows,python-3.9,pythonw
2021-10-08T22:19:00.000
69,502,251
pythonw.exe in python 3.9
Actually 5 minutes after posting the question I found the solution. I reinstalled python enabling the option "install for all users". Now the file is there..
0
0
0
53
69,505,169
1
I am currently doing data processing in python, but the amount of data I handle is so large that it takes an enormous amount of time. I would like to run the data processing job every day between 6pm and 6am, and proceed gradually. Is it possible to do that with APScheduler?
1
0
false
python,cron,apscheduler
2021-10-09T04:34:00.000
69,503,767
How to add a job to be started at a fixed time every day and to be finished at a fixed time with APScheduler
APScheduler can schedule the job to start, but your code needs to check the time on each iteration and return from the call if the hour is between 7 am and 5 pm.
0
0
1
523
69,508,559
1
How do you convert a column of dates of the form "2020-06-30 15:20:13.078196+00:00" to datetime in pandas? This is what I have done: pd.concat([df, df.date_string.apply(lambda s: pd.Series({'date':datetime.strptime(s, '%Y-%m-%dT%H:%M:%S.%f%z')}))], axis=1) pd.concat([df, df.file_created.apply(lambda s: pd.Series({'date':datetime.strptime(s, '%Y-%m-%dT%H:%M:%S.%f.%z')}))], axis=1) pd.concat([df, df.file_created.apply(lambda s: pd.Series({'date':datetime.strptime(s, '%Y-%m-%dT%H:%M:%S.%f:%z')}))], axis=1) I get the error - time data '2020-06-30 15:20:13.078196+00:00' does not match format in all cases. Any help is appreciated.
2
0
false
python,pandas,string,dataframe,datetime
2021-10-09T12:25:00.000
69,506,719
Dealing with "+00:00" in datetime format
None of the formats mentioned by you above matches your sample. Try this "%Y-%m-%d %H:%M:%S.%f%z" (Notice the space before %H).
0.099668
1
0
314
69,553,845
1
Specifically, I want to use match/case in my python code but Sublime doesn't recognize them as keywords, highlight, auto indent or anything. How do you make the needed update?
1
2
false
sublimetext3,python-3.10
2021-10-09T19:05:00.000
69,509,771
How to update Sublime Text 3 to work with Python 3.10 syntax
I think that for now the default Sublime Text 3 Python syntax highlighting is not compatible with the new features, and the best thing would be to wait for a new update or create a custom syntax highlighting based of the built in one.
0
0
0
250
69,511,958
1
I have both python 3.8 and 3.9 on my Mac. when I install a new package by pip3 install ..., the package will go to the python 3.9 folder, but apparently the executable commands to run in terminal is in python 3.8 folder, so even though I installed a package, I cannot run the command lines come with it. I guess I have to somehow point the path of python to version 3.9? Can somebody help me to fix this?
1
0
false
python,pip,python-3.9
2021-10-10T02:45:00.000
69,511,914
Pip installs packages into the python 3.9 folder, but the executable commands are in the python 3.8
Try which python3.9 to definitively determine if and where Python 3.9 lives on your path. Then run python3.9 -m pip install … to ensure that the command gets executed against the Python 3.9 interpreter.
0
0
2
49
69,522,481
1
I want to update the selected python interpreter inside vs code from a script. I tried: .vscode/settings.json in the workspace allows setting python.defaultInterpreterPath but it works only once. Even if select "default interpreter" in the UI (e.g. python 3.8), close vs code, change the setting to 3.9, open vscode again, vs code remembers 3.8. $config_path/User/workspaceStorage/.../state.vscdb also contains a key ms-python.python which got data for the selected interpreter autoSelectedWorkspacePythonInterpreter - but that does not even change when changing the interpreter in vscode (from the name of the setting that kind of makes sense) Where does vs code even store the information which interpreter is selected by hand? Any pointers welcome how to change the used python interpreter (preferable from a script running outsideof vs code, but I would also write a vs code extention if that is easier :))
1
0
true
python,visual-studio-code,vscode-settings,vscode-extensions
2021-10-10T09:02:00.000
69,513,772
Update selected python interpreter from script
$config_path/User/globalStorage/.../state.vscdb --> ms-python.python.
1.2
1
1
147
69,521,041
1
Does anyone know if we can use multiple RegisterTransitCallback for different dimensions in ortools vrp? What I have noticed in my code shows that only the last RegisterTransitCallback will take effect for all the added dimensions.
1
1
false
python-3.x,or-tools
2021-10-11T00:58:00.000
69,520,043
can we use multiple RegisterTransitCallback in ortools?
I is common to have one callback for time and one for distance. This is shown in vrptw examples. So yes.
0.197375
1
1
75
69,531,689
1
my python application imports other python packages in other locations on the filesystem dynamically at runtime. It then calls certain functions in these packages and supplies data objects from the main application. The issue is that coding these external packages there is no code completion in regard to the main apps code. Because these data objects are only supplied at runtime, as are their classes (which are already imported by then main app when calling the package) the package itself cannot reference them in any way (circular import). Since the package doesnt know about the objects up until it's running, Code Completion can't suggest any methods of these objects for example either. Is there any way for me to provide PyCharms Code Completion with a reference to the main application, so it can autocomplete my code? By this I mean suggestions for objects of the classes of my main app, autocomplete for native python packages works fine of course. The packages are imported by dynamically adding their path to the path variable, I tried to also add them to the interpreter path, however this did not work.
1
0
false
python,pycharm,code-completion
2021-10-11T13:19:00.000
69,526,900
PyCharm Code Completion for files outside project directory
So if you have main for your main application and foo0 and foo1 for different versions of your remote package, if you are currently developing foo1 what you can do is open your main project then add foo1 as a context root to main. To add a context root: Settings| Project: ... | Project Structure | + Add Context Root. Then select foo1. If you want to switch your development to foo0, you would need to remove foo1 as a context root and add foo0.
0.197375
1
2
308
69,535,714
1
I had this problem since I started using the code runner extension. a file called tempCodeRunnerFile.py get created and runs when I click on the run button it really annoying, I tried deleting the tempCodeRunnerFile.py file but it keeps coming back.
1
0
true
python,visual-studio-code,vscode-code-runner
2021-10-11T17:07:00.000
69,530,044
tempCodeRunnerFile.py problem in visual sudio
It indicates that you have selected part of the code snippet and run it. You can add "code-runner.ignoreSelection": true in the settings.json file to avoid it.
1.2
1
0
102
69,538,381
1
I wanna move a card from List A to List B using Trello API. I guess one way is to just copy a card and paste it in List B then delete the card from List A. Is there any straightforward way to achieve this goal?
1
0
false
python,trello
2021-10-12T08:58:00.000
69,537,699
move cards between lists using Trello API (python)
just use PUT method and add idList query! url = "https://api.trello.com/1/cards/{id}"
0
0
2
31
69,547,489
1
I have a code that needs to get an input from the console. I am doing it to be able to debbug a code with input from console becuase pycharm does not allow me to pause during execution. I want to be able to provided the input i want beforehand , i.e to provide it automatically through the code as if it was provided from the console. Is this possible?
1
0
true
python
2021-10-12T21:56:00.000
69,547,462
Automatic input to program
If you use input(), PyCharm will pause execution to wait for input just as if you run in the console. Alternatively, you can use sys.argv to take command line parameters. You can add these parameters to the run configuration in pycharm.
1.2
1
0
124
70,262,048
1
I actually made an executable with some ui in tkinter for automating some tasks in my Windows 10 computer. But since Windows 11 started rolling out, I was wondering if my app can still run in Windows 11.
1
1
false
python,windows,tkinter,exe
2021-10-13T08:54:00.000
69,552,507
Can windows 10 standalone executables (in Python) run on Windows 11?
Yes it will indeed work, if your app doesn't use features that were deprecated in Windows 11. You can also run it in compatibility mode if there is some unexpected behavior.
0
0
2
34
69,558,284
1
I just noticed an odd behavior in Dymola 2022, and I wonder if and how can I take care of it from the Python interface. Odd behavior, because I expect Dymola to consistently set the working directory at .\Documents\Dymola at startup, unless told otherwise. However, when I instantiate Dymola from its Python interface, at startup the working directory is set according to the setting Tools > Options > Settings > Save startup directory as follows: Do not save - then when I instantiate Dymola, the current directory is set as the directory where the python environment is open. Possibly interesting here: the directory where the python environment is open is not the directory where the function is located. Example: in VSCode open folder > .\project, the function is in .\project\functions\dymIO\instantiateDymola.py, then the Dymola working directory at startup is set at .\project Save this directory > .\Documents\Dymola - then the current directory is set reliably at .\Documents\Dymola One solution/fix would be to set the working directory after Dymola is instantiated, I am aware of it. My question is rather to get an understanding of what might be going on with this behavior, and if there is a possibility to take care of it right at startup rather than afterwards
1
0
false
python,dymola
2021-10-13T11:19:00.000
69,554,573
Default startup directory behavior in Dymola 2022
I don't know exactly what is happening with Python at the moment, but I can answer what happens inside Dymola: When you start a program from Start-Menu the current directory is as default set to the installation directory of the program (in this case Dymola). Not important: When Dymola is started it first ensures that .\Documents\Dymola exists. Not important: If the environment variable DYMOLAWORKDIRECTORY is not set it is set to .\Documents\Dymola If the current directory is the same as the installation directory of Dymola then it sets current directory to .\Documents\Dymola - otherwise it keeps the current directory. This allows you to make a short-cut "Start Dymola Here!" And then the settings where you might have changed 'Startup Directory' is processed. But I don't know why the Python-interface changes current directory to .\project, and if you could change current directory in Python.
0.379949
2
0
87
69,566,450
3
I opened command prompt (I'm on Windows) and I typed: '''none pip3 install discord ''' Then it said it installed discord, and I was ready to go! (I already had Python 3.9.7 installed) Then when I opened VSCode up and typed: import discord I got this error message: "discord" is not accessedPylance Import "discord" could not be resolvedPylancereportMissingImports What does this mean, and how can I fix it? I was really looking forward to coding the bot, but don't know how, now that this is messed up.
3
0
false
python,visual-studio-code,discord
2021-10-13T15:25:00.000
69,558,197
I tried to add Python to VSCode, but it won't work
Open an integrated Terminal in VS Code, run python --version, it should be python3.9.7 which is selected as python interpreter and shown in status bar. run pip show discord to check if its location is \..\python3.9.3\lib\site-packages. If not, reinstall it.
0
0
0
87
69,558,268
3
I opened command prompt (I'm on Windows) and I typed: '''none pip3 install discord ''' Then it said it installed discord, and I was ready to go! (I already had Python 3.9.7 installed) Then when I opened VSCode up and typed: import discord I got this error message: "discord" is not accessedPylance Import "discord" could not be resolvedPylancereportMissingImports What does this mean, and how can I fix it? I was really looking forward to coding the bot, but don't know how, now that this is messed up.
3
0
false
python,visual-studio-code,discord
2021-10-13T15:25:00.000
69,558,197
I tried to add Python to VSCode, but it won't work
check in the bottom left corner of the VS Code window for which version of Python is it using. This issue usually occurs for me when I’m working in a virtual environment but VS Code is pointing to my global Python installation.
0
0
0
87
69,559,150
3
I opened command prompt (I'm on Windows) and I typed: '''none pip3 install discord ''' Then it said it installed discord, and I was ready to go! (I already had Python 3.9.7 installed) Then when I opened VSCode up and typed: import discord I got this error message: "discord" is not accessedPylance Import "discord" could not be resolvedPylancereportMissingImports What does this mean, and how can I fix it? I was really looking forward to coding the bot, but don't know how, now that this is messed up.
3
0
false
python,visual-studio-code,discord
2021-10-13T15:25:00.000
69,558,197
I tried to add Python to VSCode, but it won't work
You can change the Python Interpreter in VSCODE to solve this issue. Open settings in VSCODE by pressing Ctrl + Shift + P. Make sure your .py file is open while doing this step. Search there Python: Select Interpreter and choose the right version. Reload VSCODE and see if it works!
0
0
0
32
69,561,124
1
The Tkinter app works good after deployment with Pyinstaller, but it opens 2 windows: .exe and app (tkinter container). Any ideas? how to fix it?
1
1
false
python,pyinstaller
2021-10-13T17:47:00.000
69,560,083
Pyinstaller: It works, but .exe window and App Window is separated. Any ideas?
I'm not sure I understand completely but you may want to try saving the file as .pyw vs .py before making it an executable. you may be seeing the console running.
0
0
1
60
69,562,478
1
Is it possible to have someone not have python installed, double click on my installer and through that get an executable, the python, and the needed libraries? For that I would probably also want to know, if I can type anything but python path/file.py to run the python script. Because for that you would need to add the python installation to path. And is there a way to bypass this? To type something else instead of python like manually type the location where the executable is or so? My boss asked me this today. Don’t think that’s a common task to do with python but if I know how to do that with python, I for one can do it with python and I will also easier understand how one normally writes installers and programs with guis and such. I do like python though. I guess this is not an easy question. I really am interested though. If you can only answer the second question, I would also be very grateful because then i can figure out the rest I think.
1
0
false
python,user-interface,windows-installer
2021-10-13T21:17:00.000
69,562,437
How to make an installer for a python program
You can use pyinstaller to create an executable. pip install pyinstaller in cmd. Then cd into the directory where your file is, and type pyinstaller --onefile filename.py
0.197375
1
1
119
69,581,941
1
I have installed python using Visual Studio, but I can't use python from the command prompt. I also want to run python from the command prompt, but it is only accessible from Visual Studio. I have tried adding the path of the directory in which Visual Studio has installed python to the user environment variables, but typing python in the command prompt opens up Windows Store. Please somebody help me with this. Is there any way around or do I have to install python separately too.
3
0
true
python
2021-10-14T07:26:00.000
69,566,639
How to run python from the terminal if I installed it using Visual Studio?
thanks for replying. I figured out the answer myself, and thought to answer it for anyone in the future who comes across the same issue. I went into settings->Apps Find the python installation and click on it, select modify. Then click on "modify installation" when the python installation repair window opens, then again click on "modify", make sure to select "Add python to path", and also py launcher option also. That fixed the problem for me. Thanks, again.
1.2
0
0
48
69,567,996
1
What I wish to understand is what is good/bad practice, and why, when it comes to imports. What I want to understand is the agreed upon view by the community on the matter, if there's any one such in some PEP document or similar. What I see normally is people have a python environment, use conda/pip to install packages and all that's needed to do in the code is to use "import X" (and variants). In my current understanding this is the right way to do things. Whenever python interacts with C++ at my firm, though, it always ends up with the need to use sys.path and absolute imports (but we have some standardized paths to use as "base" and usually define relative paths based on those). There are 2 major cases: Python wrapper for C++ library (pybind/ctype/etc) - in this case the user python code must use sys.path to specify where the C++ library to import is. A project that establish communications between python and C++ (say C++ server, python clients, TCP connections and flatbuffer serialization between the two) - Here the python code lives together with the C++ code, and if it some python files end up using sys.path to import python modules from the same project but that live in a different directory - Essentially we deploy the python together with the C++ through our C++ deployment procedure. I am not fully sure if we can do something better for case #1, but case #2 seems quite unnecessary, and basically forced just by the choice to not deploy the python code through a python package manager. Choice ends up forcing us to use sys.path on both the library and user code. This seems very bad to me as basically this way of doing things doesn't allow us to fully manage our python environments (since we have some libraries that we import even thought they are not technically installed in the environment), and that is probably why I have a negative view of using sys.path for imports. But I need to find if I'm right, and if so I need some official (or almost) documents to support my case if I'm to propose fixes to our procedures.
1
0
false
python,import
2021-10-14T08:42:00.000
69,567,639
Python sys.path vs import
For your scenario 2, my understanding is you have some C++ and accompanying python in one place, and a separate python project wants to import that python. Could you structure the imported python as a package and install it to your environment with pip install path/to/package? If it's a package that you'll continue to edit, you can add the -e flag to pip install so that when the package changes your imports get the latest code.
0
0
0
113
69,617,182
1
I'm running python script present in .py file using ExecuteStreamCommand processor in Nifi. For reading a csv file pandas modules is required. I'm calling pandas in the program but I'm getting error mentioned as "No modules Pandas found" I have Python installed in my local and added to path to Command path. How to install Pandas library?
1
0
false
python-3.x,pandas,etl,apache-nifi,minify
2021-10-14T15:44:00.000
69,573,638
Python Modules in Apache Nifi
I’ve had a similar issue with other modules. What you need to do is install the Python modules on the NiFi server that your script calls. What the error message is telling you is that it’s trying to find the module called pandas but it isn’t installed on the host.
0
0
0
60
69,578,053
1
reading an excel file in python jupyter notebook i'm trying to change a column datatype of a pandas dataframe from object to float and every try I get the message of ValueError: could not convert string to float: 'Variable by base style'. What does 'Variable by base style' mean?
1
0
false
python,excel,dataframe,types,jupyter-notebook
2021-10-14T21:43:00.000
69,577,673
Can't convert object data type to float in pandas data frame
the data you're trying to convert includes an item : "Variable by base style" which obviously cannot be changed to a float.
0
0
-1
96
69,581,489
1
I want to check if a value exists in between two numbers in a sorted list and print what two numbers it exists between. For example, if the list is [1, 4, 8, 12, 16, 20] and I want to see what two numbers the number 3 is between, 1 and 4 should be printed out. Is there any way to do this in python preferably without importing a module?
2
1
false
python,list
2021-10-15T07:48:00.000
69,581,457
How to check if a value is in between values in a list? (Python)
I am not sure if there is a inbuilt function for this but you can check it very easily by iterating over the list and take a variable as input which you want to compare. If list is not sorted in that case may be you can sort the list first.
-0.099668
-1
3
122
69,586,890
1
I'm currently trying to start working with tensorflow. I work with anaconda and I tried to install the tensorflow packages in the root environment but it always displays the message: "Several errors encountered". When I looked it up it says the solution is to create another environment exclusively for tensorflow, I did and it worked. But I'd still like to know what the reason for this is.
1
0
true
python,tensorflow,anaconda,conda
2021-10-15T14:48:00.000
69,586,601
Why do I need another conda environment from tensorflow?
I have had the same question when I started out. It seemed like it is the "correct" thing to do, so I just did it, but never understood why. After working with TensorFlow for 2 years now, and on multiple machines, I realised just how specific the set of its requirements is. Only a few versions of python are compatible with it, the same thing with numpy, and if you want to use NVIDIA GPUs, good luck figuring out the specific versions of cuda and cudnn. You don't want to have to tailor most of the python-related software on your machine to running tensorflow. In order to avoid breaking it whenever you install something that requires a higher version of numpy, for example, it is best to keep it in a separate environment. This way you have an isolated "container" that keeps everything just the way TensorFlow wants it, while still being able to use other software if needed. Not to mention that there are several versions of TensorFlow and they all have different requirements.
1.2
2
3
258
69,586,712
1
While writing code in Spyder, I have accidentally pressed a control which caused Spyder to show to editors next to each other. What can I do to close one editor?
1
1
true
python,spyder,pane
2021-10-15T14:51:00.000
69,586,649
Spyder shows two editors
alt+shift+W should work, can you please try it?
1.2
4
4
72
69,591,942
1
In the realm of Python: What can a class do that a function cannot, other than organizing code/design pattern? Couldn't one technically write any class via functions? Not to say that it would be more efficient or readable but in terms of pure functionality. Said differently, can someone take any class and rewrite it using only functions?
1
1
true
python
2021-10-16T00:48:00.000
69,591,881
What can a class do that a function cannot? (Python)
About the only largely unique, commonly used, features I can think of off-hand is that classes can be polymorphic, and classes can use operator overloading. Nested functions using closure scope can do most of the stateful attribute things a class does by having each closure act as an "instance" with the function(s) defined in that closure scope sort of acting like methods, so in that sense, you could write really ugly code with "methods" sharing persistent state. But runtime dynamic polymorphism isn't an option (you could choose different functions to return closing over that shared state, but it won't let you have polymorphic extensions in any sane way). You also can't simulate existing types that overload operators; operator overloading must be done on the type, not the instance, and all user-defined functions share a single type which doesn't let you overload additional operators. To be clear, there are things you can do with classes that are better done with functions. In particular, writing your own iterable and paired iterator classes is a pain, but generator functions can be used to make iterators with no classes at all, or to define the __iter__ of an iterable without needing to write the incredible ugliness that is a user-defined iterator class. Basically, they both exist, use the one that's clearly tailored for the situation at hand.
1.2
7
3
7,108
71,726,397
2
When I try to create venv it throws this error: Error: Command '['C:\\Users\\admin\\env\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1. It is strange for me because I'm using python for a long time and never had such a problem.
4
6
false
python,pip,windows-10,virtualenv
2021-10-16T08:51:00.000
69,594,088
Error when creating venv, Error: Command '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
On Ubuntu first, install the venv of the specific python version sudo apt install python3.9-venv python3.9 -m venv myenv //specify the python version. This will create the virtual env "myenv"
1
10
2
7,108
70,344,891
2
When I try to create venv it throws this error: Error: Command '['C:\\Users\\admin\\env\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1. It is strange for me because I'm using python for a long time and never had such a problem.
4
6
false
python,pip,windows-10,virtualenv
2021-10-16T08:51:00.000
69,594,088
Error when creating venv, Error: Command '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
I am using windows 10 WSL2 ubuntu 20.04, sudo resolved my problem. sudo python3.8 -m venv venv
0.197375
4
0
91
71,133,046
1
Is there a way to select ALL the cells below the cursor (or above) in Jupyter Notebook with one command (not doing it one-by-one).
2
0
false
python-3.x,jupyter-notebook
2021-10-16T14:45:00.000
69,596,638
is there a way to select all cells below in Jupyter notebook
Alternatively you can Select the given cell, then scroll to the bottom of your notebook and Shift + Select the last cell. This will select all cells in between.
0
0
0
36
69,597,426
1
I want to save the data in a text file of my choice and be able to manage the data I need to add or remove a string anywhere in the text file (not just the beginning and end of the file). I can not keep all the data in the file as a string variable in the program because the size of the data stored in the file may be too large. I can not read the entire file, apply the changes, and rewrite the file, and I need the changes to be executed directly on the file. The main problem is that the open function can only append a string to the end of the file (not anywhere), or change a number of text characters in the middle of the text (not add new characters), or keep the text of the file from beginning to anywhere in the file and delete the rest. (Not a range of characters in the middle of the text). Python 3
1
0
false
python,text-files
2021-10-16T16:16:00.000
69,597,397
Insert or delete a subtext in a text file
You can explore file seek, you can move anywhere in the file using file.seek() with cursor position. and move through the whole file. But you have to a pointer to move forward and backwards to mark your offsets.
0
0
0
58
69,599,713
1
I'm developing a service in Python which has a package as a dependency. I've developed that dependency myself. I have a private PyPI server that contains artifacts(a wheel file) of every commit in the master branch(for both packages). I'd like to create a CI which will use pip to install the dependency from the private PyPI server(because it's faster and easier than installing from the source code itself every time). Example for the project's dependencies: packages A requires package B (which are all in the private repository and not public packages). My problem is that if I'm trying to execute a CI on the A repository right after the B repository had a merge to master, the private PyPI server won't have the latest version of B yet(Today there's a Jenkins job that is activated after every merge to master and uploads the B wheel to the private PyPI server, but it takes a few minutes until the package is being built). The result is that package A might contain an old version of B instead of using the latest version of B. Any suggestion on how to improve this process? Installing from a private PyPI, in comparison to installing directly from Gitlab decreases the time it takes to install dramatically. BTW, today I am using Gitlab's enterprise edition and Jenkins. Thanks
1
0
false
python,build,continuous-integration,multiple-repositories
2021-10-16T16:42:00.000
69,597,603
Building a pipeline for multiple-repository services
You just need to check if package B is up-to-date before you start the installation of A. So (in your Jenkins job) just put a build step to download everything for B, and after that everything for A.
0
0
0
81
69,619,324
1
I'm looking for help with terminology to explain that a unit test failed because the test script itself has errors. The statement "this unit test failed because..." usually implies that the test script is correct and it's the function under test that is incorrect. I'm looking for the other way around. Context: I'm grading a bunch of assignments in Python 3.x where students had to define some classes and subclasses while also providing the unit testing in Pytest. I would like to give succinct but correct feedback.
1
0
false
python,unit-testing,pytest,terminology
2021-10-16T19:23:00.000
69,598,892
What is the proper way to say that a unit test failed but only because the test script is broken?
Working as an SDET I often need to distinguish between bad/broken tests and bad product code. We normally do this by talking about what needs to be fixed for the test to pass (while still being a useful and valid test). Regardless of the source of the failure you're still talking about a failure in code. In both cases (if you've taken the time to identify and isolate the cause) you can say "Caused by bug on line n of file.py", or "bug within function f of file.py". It is then implied by the file we're talking about whether we're dealing with a failure caused by bad product code or bad test code. You can reinforce this implication by supplying an explanation for why that code is the source of the problem. Some contrived examples would look like: Test n failed because of a bug on line 5 of test.py. assert False will always fail, and doesn't meaningfully test anything in class.py. Test n failed because of a bug on line 20 of class.py. sub(a, b) should return a - b instead of a + b
0
0
0
76
69,604,307
1
I'm trying to make a program that answers questions on a site automatically and I have the answers stored in a file, but I cant figure out how to read between symbols that are in the file. I need to get the question and the answer which are both in bold. This is what each question looks like in the file. the comma at the end is the divide between the first and second question. {" Complete the following statement: changing state from ---(1)--- to gas is known as ---(2)---.": {"['1: liquid; 2: evaporation', '1: liquid; 2: melting', '1: solid; 2: evaporation', '1: solid; 2: melting']": "1: liquid; 2: evaporation", "['1: liquid; 2: deposition', '1: liquid; 2: sublimation', '1: solid; 2: deposition', '1: solid; 2: sublimation']": "1: solid; 2: sublimation"},
2
0
false
python
2021-10-17T12:04:00.000
69,604,152
How to get text between symbols in string Python
You can try to convert the string to a dict and then you could use dict.items()
0
0
1
56
69,604,799
1
What is the difference between the ./file.py & the python file.py commands? What I See I usually see people using ./file.py when they are using a terminal-text editor like vim or nano or emacs OR when they are using linux based operating systems like Ubuntu or Arch Linux. And I usually see python file.py from the ones who are using some other operating system. I’m probably not correct. But if it is so, what is the difference between the both? Thank You!
2
1
true
python,terminal,operating-system,editor
2021-10-17T13:25:00.000
69,604,762
“./file.py” VS “python file.py”
on linux-based operating systems, when you execute a text file, if it starts with #!/bin/python (shebang syntax), it will actually do /bin/python filename, so it is faster to do this than having to type python all the time, it is easier to make it an executable file, but there are no major differences
1.2
0
2
27
69,610,244
1
#.This program will find the area and perimeter of a circle with a radius given by the user. import math radius=int(input('enter a number for radius')) area=math.piradius2 print('area of circle %f'%area) perimeter= 2math.piradius print('perimeter of circle %f'% perimeter)
2
1
false
python,list,python-2.7
2021-10-18T02:42:00.000
69,610,229
How do change my program so that it always rounds to the nearest 2 decimal places)
Instead of %f, use %.2f when printing to round to two decimal places.
0.197375
2
1
2,098
69,612,898
1
I after installation python 3.10.0 the latest version in command prompt show me 2.7.2 version but i don't have installed other version in my system in windows
2
0
false
python
2021-10-18T08:25:00.000
69,612,874
I install python 3.10.0 and in command prompt show me version 2.7.2
If you run python --version and it returns "Python 2.7.2", you have it installed and it is the first found python in your current path. That doesn't mean you don't also have 3.10.0 installed, it just means that it isn't the first one found in your path.
0.099668
1
2
142
69,623,158
1
In Linux, the multiprocesing module uses fork as the default starting method for a new process. Why is then necessary to pickle the function passed to map? As far as I understand all the state of the process is cloned, including the functions. I can imagine why that's necessary if spawn is used but not for fork.
1
3
false
python,fork,pickle,python-multiprocessing
2021-10-18T15:47:00.000
69,618,993
Why is the function passed to Pool.map pickled when mutiprocessing uses fork as a starting method?
Job-methods like .map() don't start new processes so exploiting fork at this point would not be an option. Pool uses IPC to pass arguments to already running worker-processes and this always requires serialization (pickling). It seems there's some deeper misunderstanding with what pickling here involves, though. When you look at job-methods like .map(), the pickling for your function here just results in the qualified function-name getting send as string and the receiving process during unpickling basically just looks up the function in its global scope for a reference to it again. Now between spawn and fork there is a difference, but it already materializes as soon as worker-processes boot up (starts with initializing Pool). With spawn-context, the new worker needs to build up all reachable global objects from scratch, with fork they're already there. So your function will be cloned once during boot up when you use fork and it will save a little time. When you start sending jobs later, unpickling your sent function in the worker, with any context, just means re-referencing the function from global scope again. That's why the function needs to exist before you instantiate the pool and workers are launched, even for usage with spawn-context. So the inconveniences you might experience with not being able to pickle local or unnamed-functions (lambdas) is rooted in the problem of regaining a reference to your (then) already existing function in the worker-processes. If spawn or fork is used for setting up the worker-processes before, doesn't make a difference at this point.
0.379949
2
1
718
69,623,271
1
For the sake of experience, I'd prefer to try this in cmd and not use get-pip in pypi.org Tried changing windows account from user to administrator and a youtube instruction video. Was awarded the following error message: Successfully uninstalled pip-20.3.1 ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'C:\Users\User\AppData\Local\Temp\pip-uninstall-j78tgiwv\pip.exe' Consider using the --user option or check the permissions.
1
0
true
python,pip,upgrade
2021-10-18T22:08:00.000
69,623,079
Attempting to upgrade pip from version 20.3.1 to version 21.3. How do I use the `--user` option?
Running pip install --upgrade --user pip (like pip is suggesting) will install pip on the user site packages (not the global). This works fine on some cases, but the upgraded package will only be available to the user who installed. As I can read, your message seems harmless (it failed on a temporary file), if you run pip --version you should see the latest version. However, if that doesn't work, you may have to add the --user option to your command.
1.2
0
0
107
69,628,031
1
I'm currently learning about Docker. I'm trying to use it in my python project (I'm using Django) In my Dockerfile, I want my image to install the dependencies of my project into each new container. I just created a requirements.txt file using the command tool 'pipreqs' After looking at the content of this file, I realize that I have 2 others files related to the dependencies: Pipfile Pipfile.lock I think they have been created and updated when I was using pipenv command. My question is : Which one of these file should I use in my Dockerfile? Pipfile, Pipfile.lock or requirements.txt?
1
0
false
python,docker,dependencies,requirements,pipfile
2021-10-19T06:50:00.000
69,626,224
Which Dependencies File Should I Use for my Dockerfile?
Default choice is requirements.txt with pinned versions. Versions can be pinned by pip freeze > requirements.txt or pipenv lock -r > requirements.txt. You need Pipfile and Pipfile.lock if you going to use pipenv inside container. Then pipenv install will use your Pipfile.lock.
0
0
0
233
69,651,519
1
In Airflow for a DAG, I'm writing a monitoring task which will run again and again until a certain condition is met. In this task, when some event happened, I need to store the timestamp and retrieve this value in next task run (for the same task) and update it again if required. What's the best way to store this value? So far I have tried below approaches to store: storing in xcoms, but this value couldn't be retried in next task run as the xcom variable gets deleted for each new task run for the same DAG run. storing in Airflow Variables - this solves the purpose, I could store, update, delete as needed, but it doesn't look clean for my use case as lot of new Variables are getting generated per DAG and we have over 2k DAGs (pipelines). global variables in the python class, but the value gets overridden in next task run. Any suggestion would be helpful.
2
0
false
python,airflow
2021-10-19T09:18:00.000
69,628,179
Airflow: Best way to store a value in Airflow task that could be retrieved in the recurring task runs
If you have task that is re-run with the same "Execution Date", using Airflow Variables is your best choice. XCom will be deleted by definition when you re-run the same task with the same execution date and it won't change. Basically what you want to do is to store the "state" of task execution and it's kinda "against" Airflow's principle of idempotent tasks (where re-running the task should produce "final" results of running the task every time you run it. You want to store the state of the task between re-runs on the other hand and have it behave differently with subsequent re-runs - based on the stored state. Another option that you could use, is to store the state in an external storage (for example object in S3). This might be better in case of performance if you do not want to load your DB too much. You could come up with a "convention" of naming of such state object and pull it a start and push when you finish the task.
0
0
0
1,411
71,722,481
1
I am using databricks-connect and VS Code to develop some python code for Databricks. I would like to code and run/test everything directly from VS Code using databricks-connect to avoid dealing with Databricks web IDE. For basic notebooks, it works just fine but I would like to do the same with multiple notebooks and use imports (e.g. use import config-notebook in another notebook). However, in VS Code import another-notebook works fine but it does not work in Databricks. From what I could find, the alternative in Databricks is %run "another-notebook" but it does not work if I want to run that from VS Code (databricks-connect does not include notebook workflow). Is there any way to make notebook imports that works both in Databricks and is supported by databricks-connect ? Thanks a lot for your answers !
3
2
false
python,python-import,databricks,databricks-connect
2021-10-19T15:10:00.000
69,633,404
Import notebooks in Databricks
Well, you can create packages .whl(wheel) install in the cluster and call via import in any notebook is a breeze
0
0
1
35
69,652,329
1
I have two date columns having corresponding Dollars associated in two other column. I want to plot it in single chart, but for that data preparation in required in python. Actual table StartDate start$ EndDate End$ 5 June 500 7 June 300 7 June 600 10 June 550 8 june 900 10 June 600 Expected Table PythonDate start$ End$ 5 June 500 0 6 june 0 0 7 June 600 300 8 June 900 0 9 June 0 0 10June 0 1150 Any solution in Python?
1
0
false
python,tableau-desktop
2021-10-20T19:39:00.000
69,652,113
Data preparation to convert two date field in one
I can suggest you a basic logic, you figure out how to do it. It's not difficult to do it and it'll be a good learning too: You can read only the subset of columns you need from the input table as a single dataframe. Make such two dataframes with value as 0 for the column that you be missing and then append them together.
0.197375
1
0
72
69,653,732
1
After reading many threads here I finally have my first own question. I want to write a script in python that takes a file with names and team codes as input and stores them in a list. Then the program is supposed to find random pairs of those people, but team mates shouldn’t be in a pair. Whenever a pair is found with random.choice the two people should be pop of the list. So far so easy. But now i want to repeat this process every month and there shouldn’t be repeated pairs… My idea was to store all past combinations in another file and every time a new match is found it first will check in the list if there already has been this pair in the past. Are there any better ways to do that ? Would love to get your ideas on that!
1
0
false
python,list
2021-10-20T22:24:00.000
69,653,707
Generate unique pairs from list several times without duplicates
If you want to randomize it, you are going to need a way to store previous pairs. Either a file, or a database. It sounds like it is going to be a pretty simple program, so a json file might make the most sense for storage. Unless I'm missing something (which I often do), I believe checking it against your storage will be the only way to determine if a random pair has been selected before. Best of luck!
0
0
0
32
69,654,702
1
How do I write a regex which accepts a string 5-7 characters long, with small letters (can only zero or one duplicate) and 1 number in the middle of the string. If it is 6 characters long, a number can be either in the 2nd or 3rd position (assuming a string starts with an index of 0) Acceptable: ab3bw, fdg5bde, qwe3gk, pu2auz
1
0
false
python,regex,verification,nsregularexpression
2021-10-21T00:29:00.000
69,654,468
Regex for a string with multiple requirements
Here it is and it's quite a long one: (^[a-z]{2}\d[a-z]{2}$)|(^[a-z]{2}\d[a-z]{3}$)|(^[a-z]{3}\d[a-z]{2}$)|(^[a-z]{3}\d[a-z]{3}$) This just matches all the possible values.
0
0
0
229
69,658,926
1
I have a python project and I need to use its venv in the terminal offered by PyCharm. However, some dependencies show as not installed but they are present in the venv folder. I think the project is using another venv in the Terminal. How can I check which venv is being used in the terminal and how can I change it to be the one in the project's folder?
1
1
false
python,terminal,pycharm,virtualenv,virtual
2021-10-21T08:49:00.000
69,658,774
How to view which venv is used in pycharm in terminal?
If you execute any program using 'run' button in PyCharm, it will give you the python it is using, in your case, it should be venv. Now from Terminal use that command instead on just python/python3. For example, your are running a program using run button, you would see something like /Users/soumyabratakole/.local/share/virtualenvs/pythonProject-8Ymrt2w6/bin/python /Users/soumyabratakole/PycharmProjects/pythonProject/main.py Now you can use /Users/soumyabratakole/.local/share/virtualenvs/pythonProject-8Ymrt2w6/bin/python instead of just python from your terminal to use your venv.
0
0
0
381
71,879,405
1
I noticed that inlay hints have been added to VSCode for TypeScript and JavaScript. I was just wondering if there was a way to enable it for languages like Java and Python just like IntelliJ does.
2
0
false
python,java,visual-studio-code
2021-10-21T14:04:00.000
69,663,445
Is there a way to enable inlay hints in VSCode for other languages like Java?
VS Code Java@1.5.0 has supported inlay hint, which can be controlled by the setting java.inlayHints.parameterNames.enabled.
0
0
1
29
69,664,306
1
My question isn't about a specific code issue, but rather about the best direction to take on a Natural Language Processing challenge. I have a collection of several hundreds of Word and PDF files (from which I can then export the raw text) on the one hand, and a list of terms on the other. Terms can consist in one or more words. What I need to do is identify in which file(s) each term is used, applying stemming and lemmatization. How would I best approach this? I know how to extract text, apply tokenization, lemmatization, etc., but I'm not sure how I could search for occurrences of terms in lemmatized form inside a corpus of documents. Any hint would be most welcome. Thanks!
1
0
false
python,nlp,lemmatization
2021-10-21T14:12:00.000
69,663,570
Direction needed: finding terms in a corpus
I would suggest you create an inverted index of the documents, where you record the locations of each word in a list, with the word form as the index. Then you create a secondary index, where you have as key the lemmatised forms, and as values a list of forms that belong to the lemma. When you do a lookup of a lemmatised word, eg go, you go to the secondary index to retrieve the inflected forms, go, goes, going, went; next you go to the inverted index and get all the locations for each of the inflected forms. For ways of implementing this in an efficient manner, look at Witten/Moffat/Bell, Managing Gigabytes, which is a fantastic book on this topic. UPDATE: for multi-word units, you can work those out in the index. Looking for "software developer", look up "software" and "developer", and then merge the locations: everytime their location differs by 1, they are adjacent and you have found it. Discard all the ones where they are further apart.
0.197375
1
2
38
69,667,245
1
I have 2 feather files based on the same data. The only difference is the way the data is obtained. File 1 has a list of queries, broken out by month, that are each saved as individual files. Then each file is read into a dictionary and concatenated with pd.concat(dict[values]) in python. File 2 is another list of queries, broken out into quarters, that are each saved as individual files. Each file is then concatenated through some process in R that I'm not familiar with. Upon reading both files, I can see that the data is the same. Same number of rows, sums, etc. But File 1 is 3GB and File 2 is 6GB. Why is that?
1
1
true
python,r,feather
2021-10-21T18:31:00.000
69,667,086
2 .feather files with same data, completely different sizes?
This happens because 6GB file contains more blocks than 3GB one. Less blocks file is split, the better compression is achieved. Compare WinRar compression with and without "create solid archive" option. What is worth to mention, 6GB file may be more optimized for random read.
1.2
1
2
91
69,669,522
1
I'm trying to make a game with a leaderboard, and I have the code that writes the high scores in a file, but when multiple people play the game, they have separate leaderboards. so basically, i'm asking if there's a way to have everyone share a file in repl.it.
1
0
true
python,file,repl.it,fileshare
2021-10-21T21:53:00.000
69,669,181
How to create a leader board in repl.it python
If your code is writing to local files e.g. via open('some_file.txt'), then those are limited to the individual user's Repl.it workspaces. If you must use files, then you could use any of the Dropbox, Git, AWS S3, Google Drive Python libraries to read/write external files. However, the better solution would be to use a hosted database solution and connect Repl.it to that. Some popular (free) examples include Firebase, Mongo Atlas, or Datastax Astra. For a simple leaderboard counter, then even Grafana Cloud.
1.2
1
3
118
69,676,643
2
I'm finding the number of permutations of the lexicographically smallest string. For example, bbaa now the lexicographically smallest string is aabb So, the permutations are, (1,2,3,4), (2,1,3,4), (1,2,4,3), (2,1,4,3) which is 4. My idea for it (in python) was to find the smallest string (basically sort it into a string) and then, creating a counter which stores the count of each character. Since, we don't need a string which becomes lexicographically larger, we can only swap the same characters. Like, aaabbbcc so, a has 3 places, b has 3 places and c has only 2. Which makes the number of permutations possible, (3*3*2) And this can be implemented by multiplying the values of counter. But this approach is missing out on something important because, obviously, it doesn't pass. And I found a string, which deviates this approach: hjkegfghjkdcoiuyg Length: 18 Sorted: cdefggghhijjkkouy Counter: Counter({'g': 3, 'h': 2, 'j': 2, 'k': 2, 'c': 1, 'd': 1, 'e': 1, 'f': 1, 'i': 1, 'o': 1, 'u': 1, 'y': 1}) EDIT: So according to my algorithm, the answer should be 24 as mentioned above. But the actual answer is '48' which is twice and I tried to figure out some relation or maybe a silly mistake, but there's no silly mistake.
2
0
true
python,algorithm
2021-10-22T11:55:00.000
69,676,474
Number of permutations of the lexicographically smallest string
You need to multiply the factorials of the character counts. This is because 3 same letters creates 3! = 6 permutations: (1,2,3) (1,3,2) (2,1,3) (2,3,1) (3,1,2) (3,2,1) With this example, 3! * 2! * 2! * 2! = 6 * 2 * 2 * 2 = 48.
1.2
2
1
118
69,676,647
2
I'm finding the number of permutations of the lexicographically smallest string. For example, bbaa now the lexicographically smallest string is aabb So, the permutations are, (1,2,3,4), (2,1,3,4), (1,2,4,3), (2,1,4,3) which is 4. My idea for it (in python) was to find the smallest string (basically sort it into a string) and then, creating a counter which stores the count of each character. Since, we don't need a string which becomes lexicographically larger, we can only swap the same characters. Like, aaabbbcc so, a has 3 places, b has 3 places and c has only 2. Which makes the number of permutations possible, (3*3*2) And this can be implemented by multiplying the values of counter. But this approach is missing out on something important because, obviously, it doesn't pass. And I found a string, which deviates this approach: hjkegfghjkdcoiuyg Length: 18 Sorted: cdefggghhijjkkouy Counter: Counter({'g': 3, 'h': 2, 'j': 2, 'k': 2, 'c': 1, 'd': 1, 'e': 1, 'f': 1, 'i': 1, 'o': 1, 'u': 1, 'y': 1}) EDIT: So according to my algorithm, the answer should be 24 as mentioned above. But the actual answer is '48' which is twice and I tried to figure out some relation or maybe a silly mistake, but there's no silly mistake.
2
0
false
python,algorithm
2021-10-22T11:55:00.000
69,676,474
Number of permutations of the lexicographically smallest string
Counting permutations is done with factorials. Your answer should be 3! * 2! * 2! * 2!
0.099668
1
0
454
69,875,995
1
Having trouble with pip install web3 using python3.10 on a macOS bigsur 11.6 says Building wheel for cytoolz error I have already tried the following: xcode-select --install running virtual environment bumping down to python3.7 (worked for others) any more new things to try? help
2
0
false
python,web3
2021-10-22T17:32:00.000
69,680,990
having problem installing web3 with pip installer (cytoolz error)
I had the same issue with Python 3.10.0. I downgraded to Python3.9.7 and was able to build cytoolz wheel and eth-brownie installation worked!
0
0
1
171
69,834,789
1
some versions ago in Blender 3D there was an automatic logging of the python statements corresponding to actions performed in the GUI (at least when blender was started from the console). In the current versions (2.93/3.0x) I cannot find this option anwhere. Is there an addon available to recover this very useful feature or any other way to find out the corresponding statements for the actions in the GUI? Thank you for any link or information!
1
0
false
python,console,blender,script
2021-10-23T09:16:00.000
69,686,724
Blender Python Statement Console Logging
O.k., I just found it: there is a window type "info". All python statements are logged there and can be selected and copied comfortably.
0.197375
1
1
138
69,687,830
1
I already fixed this, but I will post the question anyways and answer it so if there are other people having this issue they may find this. I installed blender a while ago and did some stuff using python. I can't recall what exactly I did, it was for a school project. However, when I recently tried to use pip to install something I got the following message: Error in launcher: Unable to create process when using "path to python my blender folder" Even if you get this answer due to another situation my solution might still help you.
1
1
false
python,pip
2021-10-23T11:38:00.000
69,687,777
Pip Fatal Error in launcher: Unable to create process when using ""
This worked for me: First I uninstalled Blender. Then I uninstalled python and reinstalled the newest version. I deleted every environment variable path I could find leading to an old python version. In the Terminal I entered where pip and still got some paths leading to old python versions, I went to these locations and deleted every folder labeled with an old python version, in my case these locations were C:\Python37and C:\Users\myusername\Appdata\Roaming\Python And that's it. After that pip worked as it should.
0.197375
1
1
355
69,696,950
2
I have to use some existing classes. When I run these I always get the error 'IndentationError: expected an indented block'. I discovered it could be resolved by replacing the tab to 4 spaces. Because I have a lott of these classes and the classes that I want to use are not small, I was wondering if there is an easy way to replace all tabs with 4 places in one step. I use Spyder with anaconda.
2
0
false
python,tabs,spyder,space,spaces
2021-10-24T12:47:00.000
69,696,863
How to replace tab with 4 spaces in an existing class in python (spyder)
Open your .py file in a text editor, highlight and copy one of the tabs, do a find and replace (usually ctrl + F), paste in the tab that you copied, and replace it with four spaces
0
0