Coder Social home page Coder Social logo

codex_py2cpp's Introduction

Alex 🔭

M.Sc. AI & Robotics student at the Technical University of Munich

  

codex_py2cpp's People

Contributors

alxschwrz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codex_py2cpp's Issues

OpenAI engine needed.

Hi, nice work, but I could not convert your "simpleScript.py" using "python2cppconverter.py" because I got the error:

openai.error.InvalidRequestError: No such model: code-davinci-002

But, worked with text-davinci-002 engine.

openai.error.InvalidRequestError: That model does not exist

Hello,i want to convert my pyscript to cpp,but i think there are some troubles
File "python2cppconverter.py", line 131, in <module> iterate_for_compilable_solution(prompt=prompt, maxIterations=3) File "python2cppconverter.py", line 111, in iterate_for_compilable_solution response = generate_completion(prompt, num_tokens=MAX_TOKENS_DEFAULT) File "python2cppconverter.py", line 73, in generate_completion top_p=1.0, frequency_penalty=0.0, presence_penalty=0.0) File "/home/dby/anaconda3/envs/rl/lib/python3.7/site-packages/openai/api_resources/completion.py", line 25, in create return super().create(*args, **kwargs) File "/home/dby/anaconda3/envs/rl/lib/python3.7/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 122, in create request_timeout=request_timeout, File "/home/dby/anaconda3/envs/rl/lib/python3.7/site-packages/openai/api_requestor.py", line 181, in request resp, got_stream = self._interpret_response(result, stream) File "/home/dby/anaconda3/envs/rl/lib/python3.7/site-packages/openai/api_requestor.py", line 397, in _interpret_response result.content, result.status_code, result.headers, stream=False File "/home/dby/anaconda3/envs/rl/lib/python3.7/site-packages/openai/api_requestor.py", line 430, in _interpret_response_line rbody, rcode, resp.data, rheaders, stream_error=stream_error openai.error.InvalidRequestError: That model does not exist

Is this only for simple print script or?

Is this only for simple python script. like few lines of print?
I am asking because some 'harder' python script can't be converted. Always errors!

I am trying on Ubuntu 22.04 and I don't need *.exe but *.cpp.

For example, this is very simple code and it can't be converted without errors:

import sys
py_ver = sys.version[0]

def is_url_file_alive(url, timeout):
    try:
        if py_ver == '2':
            import urllib2
            try:
                request = urllib2.Request(url)
                response = urllib2.urlopen(request, timeout=timeout)
                return True
            except:
                return False
        else:
            import urllib.request, urllib.error, urllib.parse
            try:
                request = urllib.request.Request(url)
                response = urllib.request.urlopen(request, timeout=timeout)
                return True
            except:
                return False
    except:
        return False

above code come with errors:

C++ File: simpleScript.cpp
Compiled Executable: simpleScript.exe
simpleScript.cpp:2:35: error: ‘string’ in namespace ‘std’ does not name a type
    2 | bool is_url_file_alive(const std::string& url, int timeout)
      |                                   ^~~~~~
simpleScript.cpp:1:1: note: ‘std::string’ is defined in header ‘<string>’; did you forget to ‘#include <string>’?
  +++ |+#include <string>
    1 | // C++ Code generated from Python Code:
cnc@cnc-x:~/codex_py2cpp$ simpleScript.cpp: In function ‘bool is_url_file_alive(const int&, int)’:
simpleScript.cpp:6:14: error: ‘string’ is not a member of ‘std’
    6 |         std::string command = "wget --spider " + url + " -t 1 -T " + std::to_string(timeout);
      |              ^~~~~~
simpleScript.cpp:6:14: note: ‘std::string’ is defined in header ‘<string>’; did you forget to ‘#include <string>’?
simpleScript.cpp:7:26: error: ‘command’ was not declared in this scope
    7 |         int ret = system(command.c_str());
      |                          ^~~~~~~
simpleScript.cpp:7:19: error: ‘system’ was not declared in this scope
    7 |         int ret = system(command.c_str());
      |                   ^~~~~~

Some bigger python scripts can't even starts to convert.
I can't put the codes here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.