ValueError: the environment variable is longer than 32767 characters

Description:

I’ve got this error on Windows 10. If I’ll generate fewer amount of notes (about one page of score), it works fine. So that’s it, my score is too big?

Error printout:

Traceback (most recent call last):
  File "C:\pycharm\scamp\main.py", line 138, in <module>
    ).show()
  File "C:\pycharm\scamp\venv\lib\site-packages\scamp\score.py", line 652, in show
    abjad().show(self.to_abjad(wrap_as_file=True, non_score_blocks=non_score_blocks, **lilypond_file_args))
  File "C:\pycharm\scamp\venv\lib\site-packages\scamp\score.py", line 1203, in to_abjad
    return ScoreComponent.to_abjad(self, wrap_as_file=wrap_as_file, non_score_blocks=non_score_blocks,
  File "C:\pycharm\scamp\venv\lib\site-packages\scamp\score.py", line 519, in to_abjad
    return self._to_abjad_lilypond_file(non_score_blocks=non_score_blocks, **lilypond_file_args)
  File "C:\pycharm\scamp\venv\lib\site-packages\scamp\score.py", line 543, in _to_abjad_lilypond_file
    abjad_object = self._to_abjad()
  File "C:\pycharm\scamp\venv\lib\site-packages\scamp\score.py", line 971, in _to_abjad
    abjad_score = abjad().Score([part._to_abjad() for part in self.parts])
  File "C:\pycharm\scamp\venv\lib\site-packages\scamp\score.py", line 971, in <listcomp>
    abjad_score = abjad().Score([part._to_abjad() for part in self.parts])
  File "C:\pycharm\scamp\venv\lib\site-packages\scamp\score.py", line 1594, in _to_abjad
    _join_same_source_abjad_note_group(same_source_group)
  File "C:\pycharm\scamp\venv\lib\site-packages\scamp\score.py", line 311, in _join_same_source_abjad_note_group
    abjad().tie(note_pair)
  File "C:\pycharm\scamp\venv\lib\site-packages\scamp\_dependencies.py", line 190, in abjad
    os.environ["PATH"] += os.pathsep + engraving_settings.lilypond_dir
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\os.py", line 685, in __setitem__
    putenv(key, value)
ValueError: the environment variable is longer than 32767 characters

The full code that resulted in the error:

import math

from scamp import *
import sys
import random
import algorithm

s = Session()
s.tempo = 240
s.fast_forward()

# s.print_available_midi_output_devices()

pitches = []
dur = []
seed = random.randrange(sys.maxsize)
# seed = 7058047395806553335 1173009000433458687 4834867942578893545
random.seed(seed)
print("Seed was: ", seed)
low = 61
high = 66
min = 30
max = 88

while len(pitches) < 50:
    durations = []
    if low > min:
        low = math.ceil(low - 0.1 * len(pitches))
    if high < max:
        high = math.floor(high + 0.1 * len(pitches))
    new_pitch = algorithm.new_pitches(low, high)
    pitches.append(new_pitch)
    for i in new_pitch:
        durations.append(int(8 / random.uniform(1, len(pitches)/10 + 0.01)) / 4)
    dur.append(durations)
    pitches.append([None])
    dur.append([random.uniform(1,3) / random.uniform(1, len(pitches)/10 + 0.01)])

print(pitches)
print(dur)

flat_dur = [item for sublist in dur for item in sublist]

piano = s.new_midi_part("piano", midi_output_device=1, num_channels=15)
acc = s.new_midi_part("accordion", midi_output_device=2, num_channels=15)


def one():
    for i in range(len(pitches)):
        for j in range(len(pitches[i])):
            r = random.random()
            cc = 'param_12: ' + str(r)
            dist = 'param_63: ' + str(r)
            if pitches[i][j] is None:
                p = None
                d = int(8 * (dur[i][j] / random.randint(1, 3))) / 4
            else:
                p = pitches[i][j]
                d = dur[i][j]
            print(p, d)
            piano.play_note(p, 1.0, d, [cc, dist])
    counter = 0

def two():
    acc.play_note(None, 1.0, 1)
    for i in range(len(pitches)):
        for j in range(len(pitches[i])):
            r = random.random()
            cc = 'param_12: ' + str(r)
            dist = 'param_63: ' + str(r)
            if pitches[i][j] is None:
                p = None
                d = int(8 * (dur[i][j] / random.randint(1, 3))) / 4
            else:
                p = pitches[i][j]
                d = dur[i][j]
            print(p, d)
            acc.play_note(p, 1.0, d, [cc, dist])
    counter = 0

s.start_transcribing()
s.fork(one)
s.fork(two)

s.wait_for_children_to_finish()
performance = s.stop_transcribing()
performance.to_score(
    title="Accordion music",
    simplicity_preference=5,
).show()

This is a genuine bug! I think I understand the issue, but it will take me a moment to fix it.

Thanks a lot! I’ll wait. SCAMP is a new way to compose for me, very exciting.

Good morning. I am getting the same error too. Lilypond has been added to my PATH and it’s correctly responding to ‘lilypond --version’ when prompted. I am running it on Windows 10.

Great product by the way. Cant wait to get my teeth into it :-).

Thanks Mark

I used this simple workaround for now. Small fragments of score transcribes without this error, then I’ve just copy-paste small parts of Lilypond code into one big .ly file.

Thank you very much! Will try it out!

Hi all,

I think I fixed it — try upgrading with pip3 --upgrade scamp!

Yes, now it works fine with full score! Thank you so much!

PS: tomorrow will be the premiere of my music for accordion and synth, completely created in SCAMP. I’ll talk about it in the lecture.

Please share a score/recording here if you get a chance!

Thanks, with pleasure: Ping timeout