it’s been happening for all my codes. and if it’s errors, at least, it will give me a syntax error in the console, but it isn’t even passing the module installation, talk more of running the program
I’ve tried it. It ain’t working
savardo
February 12, 2023, 11:24pm
23
To install a module, you need to type $ pip install whatever_module
in the shell. This is because you probably turned off guessImports
like you mentioned.
Afterwards, once you are done importing all the necessary imports, run the code and check for any errors and fix them.
1 Like
Please don’t dupe topics, but my answer is this:
bigminiboss:
The Following is not error free but will run
Change the .replit
file to:
# The command that runs the program. If the interpreter field is set, it will have priority and this run command will do nothing
run = "python3 main.py"
# The primary language of the repl. There can be others, though!
language = "python3"
entrypoint = "main.py"
# A list of globs that specify which files and directories should
# be hidden in the workspace.
hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"]
# Specifies which nix channel to use when building the environment.
[nix]
channel = "stable-22_11"
# The command to start the interpreter.
[interpreter]
[interpreter.command]
args = [
"stderred",
"--",
"prybar-python310",
"-q",
"--ps1",
"\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
"-i",
]
env = { LD_LIBRARY_PATH = "$PYTHON_LD_LIBRARY_PATH" }
[env]
VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv"
PATH = "${VIRTUAL_ENV}/bin"
PYTHONPATH = "${VIRTUAL_ENV}/lib/python3.10/site-packages"
REPLIT_POETRY_PYPI_REPOSITORY = "https://package-proxy.replit.com/pypi/"
MPLBACKEND = "TkAgg"
POETRY_CACHE_DIR = "${HOME}/${REPL_SLUG}/.cache/pypoetry"
# Enable unit tests. This is only supported for a few languages.
[unitTest]
language = "python3"
# Add a debugger!
[debugger]
support = true
# How to start the debugger.
[debugger.interactive]
transport = "localhost:0"
startCommand = ["dap-python", "main.py"]
# How to communicate with the debugger.
[debugger.interactive.integratedAdapter]
dapTcpAddress = "localhost:0"
# How to tell the debugger to start a debugging session.
[debugger.interactive.initializeMessage]
command = "initialize"
type = "request"
[debugger.interactive.initializeMessage.arguments]
adapterID = "debugpy"
clientID = "replit"
clientName = "replit.com"
columnsStartAt1 = true
linesStartAt1 = true
pathFormat = "path"
supportsInvalidatedEvent = true
supportsProgressReporting = true
supportsRunInTerminalRequest = true
supportsVariablePaging = true
supportsVariableType = true
# How to tell the debugger to start the debuggee application.
[debugger.interactive.launchMessage]
command = "attach"
type = "request"
[debugger.interactive.launchMessage.arguments]
logging = {}
# Configures the packager.
[packager]
language = "python3"
ignoredPackages = ["unit_tests"]
[packager.features]
enabledForHosting = false
# Enable searching packages from the sidebar.
packageSearch = true
# Enable guessing what packages are needed from the code.
guessImports = false
# These are the files that need to be preserved when this
# language template is used as the base language template
# for Python repos imported from GitHub
[gitHubImport]
requiredFiles = [".replit", "replit.nix", ".config", "venv"]
[languages]
[languages.python3]
pattern = "**/*.py"
[languages.python3.languageServer]
start = "pylsp"
go to shell and run: pip install pandas
Change the demographic_data_analyzer.py
to:
import pandas as pd
def calculate_demographic_data(print_data=True):
# Read data from file
df = pd.read_csv("adult.data.csv")
# How many of each race are represented in this dataset? This should be a Pandas series with race names as the index labels.
race_count = df['race'].value_counts()
# What is the average age of men?
average_age_men = df[df["sex"] == [Male]]["age"].mean().round(1)
# What is the percentage of people who have a Bachelor's degree?
num_bachelors = len[df['education'] == ['Bachelors']]
total_education = len[df["education"]]
percentage_bachelors = round(num_bachelors/total_education * 100, 1)
# What percentage of people with advanced education (`Bachelors`, `Masters`, or `Doctorate`) make more than 50K?
# What percentage of people without advanced education make more than 50K?
# with and without `Bachelors`, `Masters`, or `Doctorate`
higher_education = df[df['education'].isin[['Bachelor', 'Masters', 'Doctorate']]]
lower_education = df[~df['education'].isin[['Bachelor', 'Masters', 'Doctorate']]]
2 Likes
it’s a replit problem: reinstalling numpy takes WAY too long and it’s downgrading it so
2 Likes
Thanks bro, this has been working. Just that it brings in ValueErrors from the module installation files
Are there any changes you suggested on this repl codes?
yes I did suggest minimal changes to get rid of runtime errors, now it’s up to you to fix logic errors
1 Like