All Questions
Tagged with python python-2.7
63,066 questions
0
votes
0
answers
23
views
Error in Python 2 script eunning under Python 3 [duplicate]
First of all, let me say this is not my script. I need to install an older .deb package. It evidently uses Python 2, but that is deprecated on the system. I have fixed a number of obvious issues, ...
-1
votes
1
answer
61
views
Why would a simple input statement cause a runtime error? (Work@tech IDE) NZEC error
Since replit has started charging for collaborative IDE's i've been trying to explore good alternatives.
I am experiencing NZEC error when trying to run a simple program such as:
answer = ""
...
1
vote
0
answers
35
views
ImportError when unpickling an object in Python 2.7
I have a pickled object of MyCustomClass. It is pickled using Python 2.7.8 builtin pickle module:
# mymodule.py
import pickle
class MyCustomClass:
def __init__(self):
attr1 = None
def ...
0
votes
0
answers
61
views
Unable to locate #audio-source element in captcha solver using DrissionPage
I'm working on automating the solving of a reCAPTCHA using Python, pydub, and DrissionPage. I've managed to reach the point where the audio challenge is presented. However, I'm having trouble locating ...
0
votes
0
answers
74
views
Is there a way to capture Event from focused Text widget before it gets to widget
QUESTION:
Is there a better way to do this? Can I hijack the Event before it reaches the focused Text widget? Or is emulating the behavior I want the best I can do?
PROBLEM:
Using Python 2.7 Tkinter....
1
vote
0
answers
42
views
opcua python2.7 -- Writing to OPC UA server using .set_values(nodes, values)
I'd like to write multiple nodes to the OPC UA server. Therefore I use the .set_values() method of the opcua lib. I've to use the opcua lib in cause of python version 2.7.
Using the .set_values() ...
1
vote
0
answers
43
views
Python 2.7: difference between codecs.open(<f>, 'r', encoding=<enc>) and <string>.encode(<enc>)
What is the difference between code like this:
with codecs.open(<file path>, 'r', encoding='my_enc') as f:
json.load(f)
string = json['key']
and code like this:
with open(<file path>, ...
-4
votes
2
answers
116
views
How to turn a tuple of lists into a list? [closed]
I am using Python 2.7 to turn a tuple of lists (of 2 elements) of float into a list of floats (([1.0],[2.0]) => [1.0,2.0]) like the following:
[tuple_lists[0][0],tuple_lists[1][0]]
Is there a ...
0
votes
0
answers
35
views
How to remove connecting lines in the line plot for large dataset?
i have a large dataset of around 4000 line, and with python i want to plot all the lines in graph, but as showen in the figure below all the time shows those lines connecting the start and the end of ...
0
votes
1
answer
195
views
When making a Python 2.7 venv in Pycharm, I am getting a syntax error and told it is using Python 3.11? How do I use Python 2.7?
I have a project that is in Python 2.7, it has to be in 2.7 and upgrading is NOT an option so please don't tell me I should just do that, I am using a python package for a specific software that has ...
0
votes
0
answers
45
views
Custom modules are not working even after adding them to __init__.py
I am trying to get all the odoo projects from my other system to a new system and while doing so, I am facing a problem during moving my files.
When I add previously created custom_addons folder to ...
-2
votes
1
answer
46
views
Transpose of a matrix_comp
given a matrix of 3*2 A= [[10,20],[74,25],[340,20]] to get output = [[10,30,-10,20],[74,99,49,25],[340,360,320,20]] where the 1st and 2nd col values will be the 1st and 4th col values and 2nd, 3rd col ...
0
votes
0
answers
39
views
Cannot install Database-library package in Python2 using pip
I am new to python and moving one test from one (working) to another physical machine (new).
in the process , One of python file has -> from DAL.database import DBC
when I do 'pip2 freeze' on both ...
0
votes
0
answers
82
views
How to make my Telegram bot stop working at 16:15 and not work on Fridays?
I have a Telegram bot written in Python using the Telethon library. The bot is supposed to function from 10:00 to 16:15 from Saturday to Thursday, and it should be completely inactive on Fridays. ...
0
votes
0
answers
49
views
Could not find py4J jar at
I am trying to run my PMML pre-trained model in Python 3.9, but no matter what I do I have this error Could Not find py4j jar at.
None of the solutions provided on the blogs are working. And, even if ...
0
votes
1
answer
77
views
how to conver new key into old in python3 ndb
Here my code
new_key= ndb.Key(urlsafe = request.user_key)
this is written in python3 ndb
this will return us key and we change in urlsafe
key = new_key.urlsafe()
key.decode(encoding="utf-8&...
1
vote
2
answers
37
views
TypeConversion of a string with float values to integer is throwing error
I have written the following code:
typConvInt = int('3.3')
print(typConvInt)
But compiler is throwing an error.
ErrorMessage:
Traceback (most recent call last):
File "E:\Trainings\...
2
votes
2
answers
80
views
Change mantissa in scientific notation from 0-1 instead of 1-10
I want to format a number so that the mantissa is between 0 and 1 instead of 1 and 10 in scientific notation.
For example;
a=7.365
print("{:.6e}".format(a))
This will output 7.365000e+00, ...
0
votes
0
answers
50
views
How to change the python version of a virtual enviremnet?
I am writing a Django React web app and I am required to install Dlib for a specific component to work (to install face_recognition library). However I am unable to do so because I used Python 3.12 to ...
0
votes
2
answers
54
views
Converting python 3 to 2.7.5 F string to .formated
I learned all of my python on 3.0 and greater and come to find out the server that I need to put my script on is 2.7.5 which means no f strings. I am having issues converting my script from F strings ...
0
votes
0
answers
30
views
AttributeError when running unittest with coverage in Python 2.7 on WSL
I'm encountering an error while attempting to run unit tests with unittest and coverage in Python 2.7 on a Windows 11 system using WSL (Windows Subsystem for Linux). The error message suggests an ...
2
votes
1
answer
106
views
Is there a way to mock .strip() for unit testing in Python 2.7's unittest module?
I am using Python 2.7 for a coding project. I'd love to switch to Python 3, but unfortunately I'm writing scripts for a program that only has a python package in 2.7 and even if it had one in 3 our ...
0
votes
0
answers
85
views
Unable install python-ldap in python 2.7.9 on windows 11
I cannot install the required package because it needs Visual Studio C++ 9.0, which is no longer supported. Unfortunately, I can't upgrade my Python version because I need it for Odoo 8 development. ...
3
votes
3
answers
371
views
Why is format() throwing ValueError: Unknown format code 'f' for object of type 'str' when I'm not inputting a string?
I am using Python 2.7. (Switching to Python 3 for this particular code is not an option, please don't suggest it.) I am writing unit tests for some code.
Here is the relevant piece of code:
class ...
0
votes
1
answer
53
views
Generate Python 2.7 dependency tree for offline installation [duplicate]
I need to install the dateutil Python library to run a script at work.
The problem is that our machines do not have internet access so we cannot use pip2.7 to install the dependencies. What we can do ...
1
vote
2
answers
56
views
Python Pandas data frame column split based on previous unique columns combination [duplicate]
I have a data frame like below:
TAG TAG_NAME METRIC METRIC_NAME CAPTURE_DATE MB
DB PRO SPACE A 2024-03-01 3
DB PRO SPACE B 2024-03-01 4
DB ...
0
votes
2
answers
77
views
List of lists (double [[) in Python
This is a really basic thing but after reading the documentation I am still not able to do. I just want to create a list of 9 sublists as follows
[[0, 0.05, 0.1, ..., 25],[0, 0.05, 0.1, ..., 25],[0, 0....
-1
votes
2
answers
72
views
can't find the page URL
I got the same error while writing code.
I started making this project using a video tutorial on YouTube. I think the problem is in the URLConf but I can’t find this problem myself.
Essentially the ...
0
votes
0
answers
29
views
Error Building 'pycapnp' for AppScale on Ubuntu 18.04 with Python 2.7
As a Java Developer transitioning into the Python ecosystem, I've noticed a difference in how dependencies are handled between the two languages. In Java, project dependencies remain intact and the ...
0
votes
0
answers
46
views
SCRAM authentication method in Psycopg2 and Python 2.7
I have an old application based on python 2.7 which is currently using psycopg2 2.7.4 and using latest releases of postgresql I got the error "pg_connect(): Unable to connect to PostgreSQL server:...
1
vote
1
answer
41
views
Using Revit Python Shell, is it possible for the print statement to output colored text?
Using Revit Python Shell, is it possible to get a print statement to print colored text?
For example,
print "An Apple is red"
where the word "Apple" prints in red.
0
votes
1
answer
67
views
Django Tests Throw ORA-00942: table or view does not exist
I haven't found any questions with respect to Django tests and Oracle DB. I am trying to run a test on an existing application, but am running into the table or view doesn't exist error.
I am confused ...
1
vote
0
answers
38
views
simple python lambda sorting gives different results on different devices
this is my python code for apache hive udf:
#!/usr/bin/python
import sys
counter=0
delay={"carrier":0, "nas":0,"weather":0, "security":0, "late_aircraft&...
0
votes
0
answers
278
views
Problem with python server cert? - "There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed."
This command suddenly started failing on my centos image: RUN pip install --upgrade 'pip==20.3.4'.
This is the error message: Could not fetch URL https://pypi.python.org/simple/pip/: There was a ...
0
votes
1
answer
56
views
Maya Python: Drop down menu align with button
I'm relatively new to using python in Maya. I am trying to figure out how to align the drop down menu with a button. I would like for both the drop down menu and both the buttons to be aligned with ...
1
vote
1
answer
64
views
How to replace \r or \n in \r\n python2.7
How to replace \r or \n in \r\n in Python 2.7?
Input string = 'hello\r\n\n world\n \r\r\n\r\n'
Output string = 'hello\r\n\r\n world\r\n \r\n\r\n\r\n'
0
votes
1
answer
146
views
python2.7 - How to decode JSON without decoding the UTF-8 inside of it?
I need a function to decode UTF-8 encoded JSON. This function should take a UTF-8 encoded JSON string and convert it to UTF-8 encoded objects. The following code works:
# helper function
def ...
0
votes
1
answer
2k
views
Unable to Install Python 2 on Parrot OS
I'm facing an issue while trying to install Python 2 on my Parrot OS. Whenever I run the command:
sudo apt-get install python2
I receive the following output:
`Reading package lists... Done
Building ...
0
votes
0
answers
21
views
shutil.make_archive works but throws Error 13 for /root
I have a script that collects various files into a directory structure than creates a final zip archive. The directory <dir> is located at /home/<user>/<dir> and I want it to create /...
3
votes
1
answer
206
views
Unable to connect to cloud datastore from local legacy project based on python2.7 and django 1.4
I have a django==1.4 project (python==2.7) that I wanted to run and make some changes. I am unable to connect to cloud datastore from my local codebase. Right now, when I run the project using ...
1
vote
1
answer
78
views
Python json.dumps of a tuple with some UTF-8 characters, either fails or converts them. I want the encoded character retained as is
On my server, a Python script gets data from a database as a tuple. Then the script converts the tuple to a string (using json.dumps()) to be passed to the JavaScript script in the user's browser.
The ...
0
votes
1
answer
48
views
How to change numbers received from text file to integer
I used python script to read numbers form *.txt file and use that number for future works, but the number when I parse I am getting error "TypeError: int() argument must be a string, a bytes-like ...
0
votes
0
answers
109
views
how to run next js and python backend on local server?
i want to run a project on local host , where frontend is built with next.js and backend is built with python, i am attaching package.json file of frontend and backend,
package.json file of python ...
0
votes
1
answer
1k
views
OpenAI API error: "You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0
I am currently working on a gpt content creator system, and as I am using Mac it does not let me migrate to newer OpenAI library or downgrade it. Could I replace the ChatCompletion function with ...
-2
votes
2
answers
97
views
Get image from data looking like \x00\x00\x87
How do I create/get/open the image from a URL request when the response looks like this:
\x00\x00\x00 ftypavif\x00\x00\x00\ ... \x87"y~\x13 $%\\\xad ... xb5\xa07tR\x80
Much longer, of course.
An ...
1
vote
2
answers
323
views
Pylance in vscode cannot find system functions for Python 2.7
I have Python 2.7 installed on my computer and have correctly configured the path in vscode, but Pylance still prompts that it cannot find the system functions.
Due to some necessary reasons, I ...
0
votes
0
answers
30
views
symbol not found in flat namespace '__PyTrash_begin
I was trying to compile a code with instalooter login when I am getting this error symbol not found in flat namespace '__PyTrash_begin. all the other errors are mostly same but the end package looks ...
-1
votes
1
answer
37
views
Python search for the errors in the JSON
Premise: those dictionaries are strings. Those are JSON with a bad format. I search for the errors inside those JSON and print them.
example 1:
input
{
"ced": {
"CED_PH2&...
-5
votes
2
answers
44
views
Unable to execute Python Script directly [closed]
I am unable to execute Python Script directly.
enter image description here
enter image description here
whereas path to Python Environemnt is as follows:
root@UbuntuDockerGuest-1:~# python -c "...
0
votes
0
answers
80
views
Pip from Python 2.7.10 installed via pyenv-win cannot install any packages
I installed pyenv-win to create virtual environments in windows. One of the environments I need requires Python 2.7.10. To create virtual environments for Python versions below 3.3 I need to install ...