Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7582931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:33:28+00:00 2026-05-30T18:33:28+00:00

I am using Emacs 24/Org 7.8 and am having some issues with org-babel. I

  • 0

I am using Emacs 24/Org 7.8 and am having some issues with org-babel. I want to call a block of code with #+call:

#+name: square(x)
#+begin_src python
return x*x
#+end_src
#+call: square(x=6)

Evaluating #+call with C-c C-c gives the message:

variable “x” in block “square” must be assigned a default value

Any advice on how to debug this? I have the following code related org-babel in my init.el:

(org-babel-do-load-languages
     'org-babel-load-languages
     '((R . t)
       (python . t)
       (js . t)
       (scheme . t)
       (C . t)
       (lilypond . t)
       (maxima . t)
       (octave . t)))

Adding :var x=1 to the begin_src line like so:

#+name: square(x)
#+begin_src python :var x=1
return x*x
#+end_src
#+call: square(x=6)

don’t stop me from receiving the error.

Investigating with the emacs debugger, I find that ref isn’t holding "x=6", but is instead holding "x".

 (org-babel-merge-params
             (mapcar
              (lambda (ref) (cons :var ref))
              (mapcar
               (lambda (var) ;; check that each variable is initialized
         (if (string-match ".+=.+" var)
                 var
               (error
                "variable \"%s\"%s must be assigned a default value"
                var (if name (format " in block \"%s\"" name) ""))))
               (org-babel-ref-split-args (match-string 5))))
             (nth 2 info))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:33:30+00:00Added an answer on May 30, 2026 at 6:33 pm

    Treating your questions as two parts (issue with variable X and issue with emacs-lisp).

    Emacs-Lisp

    I would suggest making sure you include (emacs-lisp . t) in your list of org-babel-load-languages. That should resolve the issue with it not finding emacs-lisp. You can also try M-: (require 'ob-emacs-lisp) and your issue should be resolved (it forces it to load the emacs-lisp babel code).

    Variable Issue

    I had to do a few tests to figure out exactly where the issue was, it turns out there’s two ways to declare variables when trying to run Org Babel blocks. I’m using emacs-lisp for the test because I don’t have a python interpreter installed at the moment, but the results should be equivalent. The error message is telling you that you must by default declare a value for your variable (x=1). Once you do that your code blocks should be fine.

    * Declare variable in name
    #+name: square(x=1)
    #+begin_src emacs-lisp
      (* x x)
    #+end_src
    
    #+results: square
    : 1
    
    #+call: square(x=45)
    
    #+results: square(x=45)
    : 2025
    
    #+call: square(5)
    
    #+results: square(5)
    : 25
    
    * Declare variable in begin_src
    #+name: square2
    #+begin_src emacs-lisp :var x=1
      (* x x)
    #+end_src
    
    #+results: square2
    : 1
    
    #+call: square2(5)
    
    #+results: square2(5)
    : 25
    
    #+call: square2(x=45)
    
    #+results: square2(x=45)
    : 2025
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the ido method listed on this page: http://www.emacswiki.org/emacs/RecentFiles . I want to
I'm using emacs and auctex to write LaTeX documents. For some reason, M-e doesn't
I'm using Emacs as an editor. I want to set the tab size to
I have started using emacs org-mode recently to maintain my TODO lists. I have
I'm using emacs-calc through org-mode spreadsheet and I would like to count the number
Suppose I want to open a file in an existing Emacs session using su
I'm using emacs for python, and I'd like to have a nice useable shell
I am using emacs 23.1.1 on Ubuntu 10.04. I wish to program in Python
I am using emacs org-mode for managing my notes. Often I wish to use
I am trying to put the Microsoft Word document in emacs using org-mode. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.