Help with a basic python error

help plz, @rhyolight and @learner
traceback (most recent call last):
encoding =encode (
this is the input data

1 Like

I’m using NuPIC 1.0.5, but your error looks like a problem with your file. Did you edit it? It should have 3 header rows and 4391 rows of data. See here.


Hy @way-sal, I think it’d help to see more of your code since I’m not sure how you initialized ‘encode’. I’d check how yours lines up with this section of @learner’s document (or the API demo):

record = [‘7/2/10 0:00’, ‘21.2’]

Convert date string into Python date object

dateString = dt.strptime(record[0], “%m/%d/%y %H:%M”)

Convert data value string into float

consumption = float(record[1])

To encode, we need to provide numpy arrays for the encoders to populate

timeOfDayBits = np.zeros(timeOfDayEncoder.getWidth())
weekendBits = np.zeros(weekendEncoder.getWidth())
consumptionBits = np.zeros(scalarEncoder.getWidth())

Now we call the encoders to create bit representations for each value

timeOfDayEncoder.encodeIntoArray(dateString, timeOfDayBits)
weekendEncoder.encodeIntoArray(dateString, weekendBits)
scalarEncoder.encodeIntoArray(consumption, consumptionBits)

Concatenate all these encodings into one large encoding

encoding = np.concatenate((timeOfDayBits, weekendBits, consumptionBits))

@learnerand @sheiser1 thanks, i solve those problems but now i have this:
en français
paramètre non valide -15
paramètre non valide -15
‘mv’ n’est pas reconnu en tant que commande interne ou externe , un fichier excutable ou un fichier de commandes

in english
invalid parameter -15
invalid parameter -15
‘mv’ is not recognized as an internal or external command, an executable file or a batch file
maybe the problem that i’m on windows not linux -_-

Sure @way-sal no problem. If you’d like to show the code producing that error maybe I can help (I’m not sure where -15 should come in as a parameter). Though if its a windows vs linux issue I’ll have to defer

this the code of @learner :

I notice that he comments before the cell containing that code:

For an extra treat, you can use the code below (on Linux) to make GIFs for the first N records of data.

You said you’re on Windows right, so maybe that part won’t work. The block on code seems to produce GIF’s, which is cool and likely work doing though not necessary to getting the algorithms running.

1 Like

oops yes, that’s part of code run on Linux and is not necessary so I delete

the same error ::

That specific RuntimeError is saying that it is missing an environment variable called ‘USER’. You might try setting it to some value to see if you can get any further:


(I don’t really use Windows much myself, so this may not be very helpful)

no is not working :frowning:

Do you get the same error about the environment variable ‘USER’ not being defined, or some different error?

If it is the same error, then someone more familiar with Windows will have to help. I saw a similar error about missing environment variable ‘USER’ when installing NuPIC from source in Docker, but in my case it was resolved after setting the environment variable.

thanks @learner is very helpful , but what version of nupic do you use ? because i have a problem of modules , maybe my version of nupic can’t read some under moduls

any idea ???

Given the error, it looks like you need to define the USER environment variable. What is the code inside C:\Users\dell\Desktop\tests\

its your code :
and the other one is taken from :
pffff the same problemin

Try running these two lines of code from a fresh command line.

>> from nupic.algorithms.sdr_classifier_factory import SDRClassifierFactory
>> classifier = SDRClassifierFactory.create(steps=[1], alpha=0.01)

If you get an error there, then there’s something wrong with your setup.

1 Like

yes the same problem

I’m at a loss then. I’ve only ever run NuPIC on Linux and Mac, and since this looks like a setup issue, I’m guessing something special has to be done in Windows. I suggest reading through the forum for NuPIC+Windows topics and see if there’s something you’re missing.

I don’t want to break your system, but as a hack you could try setting the USER variable to something/anything. I’m sure a quick google will show you how to do that.


ok thanks @learner , i will try that