First project on data analysis with python issue with replit

I finished coding the mean variance std calculator but I coded in Jupyter notebook instead of replit and after copy pasting the code into Replit I ran into an error with numpy where for some reason it doesn’t recognize that I’ve installed it.
The start of the code looks just as in the template provided, in main.py mean_var_std is imported, then there’s the test file and the mean_var_std starts with importing numpy import numpy as np
I tried running pip install numpy in the shell and it did install it, but after doing this nothing changed.
Hope someone knows what the issue is about, here’s the repl link : boilerplate-mean-variance-standard-deviation-calculator - Replit

When you did pip install numpy it appeared to install successfully?

Sometimes the package manager will generate errors but the code will still run.

Try deleting pyproject.toml

Thanks for the answer.
Yes it did install, I double checked that. Just tried what you suggested and it still doesn’t run. The packager says this :" → poetry init --no-interaction --name ‘’
→ poetry add numpy
Using version ^1.26.4 for numpy

Updating dependencies
Resolving dependencies…

No dependencies to install or update"
And the compiler : “Traceback (most recent call last):
File “/home/runner/boilerplate-mean-variance-standard-deviation-calculator/main.py”, line 5, in
print(mean_var_std.calculate([0,1,2,3,4,5,6,7,8]))
File “/home/runner/boilerplate-mean-variance-standard-deviation-calculator/mean_var_std.py”, line 4, in calculate
lst =list(user_input.split(” "))
AttributeError: ‘list’ object has no attribute ‘split’
"

it looks like its telling you what the issue is here

As I said it runs on jupyter notebook there’s no such issue there.

jupyter notebook is a different environment, so you need to debug again in this environment

We can’t really tell what might be different there. Were you using the exact same input there?

Here is where the error is:

    print(user_input)
    lst =list(user_input.split(" "))

I printed user_input and it’s a list.

[0, 1, 2, 3, 4, 5, 6, 7, 8]
    print(mean_var_std.calculate([0,1,2,3,4,5,6,7,8]))
    lst =list(user_input.split(" "))
AttributeError: 'list' object has no attribute 'split'

And I get the exact same error when I test this on a notebook:

user_input = [0, 1, 2, 3, 4, 5, 6, 7, 8]
user_input.split(" ")

AttributeError                            
Traceback (most recent call last)

<ipython-input-2-b8072bdf5fa0> in <cell line: 2>()
      1 user_input = [0, 1, 2, 3, 4, 5, 6, 7, 8]
----> 2 user_input.split(" ")

AttributeError: 'list' object has no attribute 'split'

Hope this helps!

Thanks for confirming. I noticed the problem was with my code in the end, my function was relying on the input being a string , but in main the input is already a list of integers.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.