• XSS.stack #1 – первый литературный журнал от юзеров форума

Python - задай вопрос получи ответ

Пожалуйста, обратите внимание, что пользователь заблокирован
Подскажите пожалуйста в asyncio есть async.Lock(), а при multiprocessing.Lock(). Если у меня программа делится на 2 процесса и в ней 10 асинк потоков при этом запись в один файл, то как грамотно логически поставить lock?
Создай multiprocessing.Lock в основном процессе и передай его в дочерние процессы. В каждом процессе создай свой asyncio.Lock. При записи в файл сначала захватывай asyncio.Lock, затем multiprocessing.Lock и освобождай их в обратном порядке.
 
Пожалуйста, обратите внимание, что пользователь заблокирован
Hi all,

I hope you all are well.

I have written code in python and I want to convert is to a .exe or msi that works on windows.
I have tried pyinstaller but it doesn't seem to work. Do you know another way of converting python code?

Thanks a lot!


S
GPT4ALL



I'm happy to help!


Yes, there are alternative ways to convert your Python code into an executable file (.exe) or a Windows installer package (MSI). Here are a few options:


  1. Py2Exe: This is another popular tool for converting Python scripts into standalone executables. You can install it using pip: pip install py2exe. The process of creating the executable is similar to PyInstaller.
  2. Cx_Freeze: CxFreeze is a set of scripts and modules for freezing Python programs in .zip, .tar.gz, or .exe format. It's available on GitHub and can be installed using pip: pip install cx_freeze. The process of creating the executable involves writing a setup script.
  3. Nuitka: Nuitka is a Python compiler that converts your code into C++ and then compiles it to an executable file. You can install it using pip: pip install nuitka.
  4. PyInstaller with additional options: If you're having trouble with PyInstaller, try adding some extra flags or options when running the command. For example:

bash
pyinstaller --onefile --windowed your_script.py

This will create a single executable file and hide the console window.


  1. Nuitka + C++ compiler: You can also use Nuitka to compile your Python code into C++, and then use a C++ compiler like MinGW or Visual Studio to build an executable.
  2. Nuitka with MSVC: If you have Microsoft Visual Studio (MSVC) installed, you can use the nuitka --msvc option to generate a Windows installer package (.msi).

Before choosing another tool, make sure that your Python script is working correctly and doesn't rely on any specific dependencies or libraries. You may need to modify your code or add additional files to ensure compatibility with the chosen conversion method.


Remember to check the documentation for each alternative you choose, as they might have different usage patterns and requirements.
 
GPT4ALL



I'm happy to help!


Yes, there are alternative ways to convert your Python code into an executable file (.exe) or a Windows installer package (MSI). Here are a few options:


  1. Py2Exe: This is another popular tool for converting Python scripts into standalone executables. You can install it using pip: pip install py2exe. The process of creating the executable is similar to PyInstaller.
  2. Cx_Freeze: CxFreeze is a set of scripts and modules for freezing Python programs in .zip, .tar.gz, or .exe format. It's available on GitHub and can be installed using pip: pip install cx_freeze. The process of creating the executable involves writing a setup script.
  3. Nuitka: Nuitka is a Python compiler that converts your code into C++ and then compiles it to an executable file. You can install it using pip: pip install nuitka.
  4. PyInstaller with additional options: If you're having trouble with PyInstaller, try adding some extra flags or options when running the command. For example:

bash
pyinstaller --onefile --windowed your_script.py

This will create a single executable file and hide the console window.


  1. Nuitka + C++ compiler: You can also use Nuitka to compile your Python code into C++, and then use a C++ compiler like MinGW or Visual Studio to build an executable.
  2. Nuitka with MSVC: If you have Microsoft Visual Studio (MSVC) installed, you can use the nuitka --msvc option to generate a Windows installer package (.msi).

Before choosing another tool, make sure that your Python script is working correctly and doesn't rely on any specific dependencies or libraries. You may need to modify your code or add additional files to ensure compatibility with the chosen conversion method.


Remember to check the documentation for each alternative you choose, as they might have different usage patterns and requirements.
Thanks a lo for the helpt! Py2Exe worked very well!

Is there an option of those 5 which is the best for some reason? More stable and better consistency?

Thanks again for the help!


S
 
Всем привет!
Хотел бы задать вопрос касательно написания вирусов на питоне, о том какой уровень знаний нужен(пожалуйста пишите на человеческом сленге), и процесс написания стиллера по пунктам.
Всем заранее спасибо >3.
 
Всем привет!
Хотел бы задать вопрос касательно написания вирусов на питоне, о том какой уровень знаний нужен(пожалуйста пишите на человеческом сленге), и процесс написания стиллера по пунктам.
Всем заранее спасибо >3.
Средний уровень, это основы яп и основные либы + работы с базой данных и немного WinAPI ( тот же хром расшифровывать ).
 
Пожалуйста, обратите внимание, что пользователь заблокирован
If PyInstaller isn't working for you, there are a few alternative methods you can try to convert your Python script into a .exe or .msi file for Windows:

1. cx_Freeze

  • Installation:You can install cx_Freeze via pip:

    pip install cx_Freeze

  • Usage:
    • Create a setup script setup.py:

      from cx_Freeze import setup, Executable

      # Replace 'your_script.py' with the name of your script
      executables = [Executable("your_script.py")]

      setup(
      name="YourAppName",
      version="1.0",
      description="Your application description",
      executables=executables
      )


    • Run the setup script to generate the .exe:

      python setup.py build


    • The output .exe file will be located in the build directory.

2. py2exe



  • Installation:Install py2exe via pip:
    bash

  • Usage:
    • Create a setup.py file:

      from distutils.core import setup
      import py2exe

      # Replace 'your_script.py' with the name of your script
      setup(console=['your_script.py'])

    • Run the setup script:

      python setup.py py2exe
    • The .exe file will be generated in the dist directory.

3. Auto PY to EXE


  • Installation:This is a graphical interface for PyInstaller, which might make the process easier. Install it via pip:

    pip install auto-py-to-exe
  • Usage:
    • Run the tool:

      auto-py-to-exe
    • A GUI will open, allowing you to configure the conversion process and generate the .exe file.

4. Inno Setup

  • Purpose: If you need to create an .msi installer, you can use Inno Setup, a free installer for Windows programs.
  • Usage:
    • First, use one of the above methods (like PyInstaller or cx_Freeze) to create the .exe.
    • Then, use Inno Setup to wrap the .exe into an installer package.
    • You can download Inno Setup from here.
    • Create a script using the Inno Setup Script Wizard to create the installer.

Common Issues and Troubleshooting​

  • Dependencies: Ensure all your dependencies are included. Sometimes additional files or libraries are needed, and you can specify these in your setup scripts.
  • Path Issues: Make sure that the script path, Python environment, and any included paths are correct.
If one of these alternatives doesn't work, it's often helpful to check the specific error messages or logs provided to pinpoint the issue. Each of these methods has its quirks, so trying another one or adjusting the configuration may solve the problem.
Hi all,

I hope you all are well.

I have written code in python and I want to convert is to a .exe or msi that works on windows.
I have tried pyinstaller but it doesn't seem to work. Do you know another way of converting python code?

Thanks a lot!


S
 
HTTPDigestAuth(username, password) как реализовать в aiohttp?
aiohttp из коробки не поддерживает дайджест-аутентификацию, если только самому добавить
 
Последнее редактирование:
Как взять из файла по 1 записи через разделитель в цикл?
Пример файла: asdas qweqwe zxczx ytuyu (пробел разделитель)
Data = "asdas qweqwe zxczxc ytuytu"
Data = Data.split(" ")
for word in Data:
print(word)


Грамотнее конечно сделать вот так:
words = [word for word in Data.split(" ")]

При условии конечно что Data это Data = open(file_path, "r").read()
 
Data = "asdas qweqwe zxczxc ytuytu"
Data = Data.split(" ")
for word in Data:
print(word)


Грамотнее конечно сделать вот так:
words = [word for word in Data.split(" ")]

При условии конечно что Data это Data = open(file_path, "r").read()
Data = open('C:\\py\\script\\test.txt', "r").read()
Data = Data.split(" ")
for word in Data:
print(word)
IndentationError: expected an indented block
 
Data = open('C:\\py\\script\\test.txt', "r").read()
Data = Data.split(" ")
for word in Data:
print(word)
IndentationError: expected an indented block
Вам бы основы Python подучить.
Python:
Data = open('C:\\noob\\test.txt', "r").read()
Data = Data.split(" ")
for word in Data:
    print(word)

Грамотнее конечно сделать вот так
Форматируй код через теги когда подсказываешь, а то вон некоторые бездумно копируют. Не зная даже как работают отступы в питухоне =)
 
Последнее редактирование:
Вам бы основы Python подучить.
Python:
Data = open('C:\\noob\\test.txt', "r").read()
Data = Data.split(" ")
for word in Data:
    print(word)


Форматируй код через теги когда подсказываешь, а то вон некоторые бездумно копируют. Не зная даже как работают отступы в питухоне =)
Пасиб.
 
Вам бы основы Python подучить.
Python:
Data = open('C:\\noob\\test.txt', "r").read()
Data = Data.split(" ")
for word in Data:
    print(word)


Форматируй код через теги когда подсказываешь, а то вон некоторые бездумно копируют. Не зная даже как работают отступы в питухоне =)
Да я в шоке, у меня уже в глазах RIP появился когда Traceback увидел от него)))
Я уже думал я элементарное сделать не могу, а когда прочитал название ошибки прям рассмешило)))
 
Как взять из файла по 1 записи через разделитель в цикл?
Python:
line = open('file.txt', 'r', encoding='utf8').readline().split(' ')
for word in line:
    print(word)
open() - открыть файл
readline() - прочитать одну строку
split(' ') - разбить по пробелу
 
Последнее редактирование:
Python:
line = open('file.txt', 'r', encoding='utf8').readline().split(' ')
for word in line:
    print(word)
open() - открыть файл
readline() - прочитать одну строку
split(' ') - разбить по пробелу
зачем разбивать по строке, можно и так сделать:


Python:
with open(file_path, "r") as f:
    words = f.read().split("\n")
    for word in words.split(" "):
        print(word)

К тому же автор не упоминал что в файле есть "\n" и "\t".
 


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх