St.code is getting TypeError: 'str' object is not callable

  1. Running it locally
  2. App is not deployed
  3. Not public
  4. Full code
import os           
import sqlite3
import altair as alt
import streamlit as st 
import seaborn as sns    
import numpy as np             
import matplotlib.pyplot as plt 
from sodapy import Socrata
import webbrowser

# Layout configuration

# Title and Header Section
st.markdown("<h1 style='text-align: center; color: black;'>Analysis of Police Incident Reports in Norfolk, Virginia</h1>", unsafe_allow_html=True)
st.markdown("<h2 style='text-align: center; color: black;'>2015 - Present</h2>", unsafe_allow_html=True)
st.caption('Author: Stephen Grassia')

intro_text = ('''The City of Norfolk, Virginia, in-order to be more transparent, publishes a dataset caleld 'Police Incident Reports'. 
The data set includes information where an officer is dispatched, and responds to an offense, and a report of a crime is generated.
This project will utilize Pandas, SQLite3, Seaborn, MatPlotLib, and Sodapy to analyze police incidents in the past 5 years.''')

# Links
if st.button('Data'):
    url = f'


# Table of Contents
st.subheader("Table of Contents")
    ## Table of Contents 
1. Import Libraries
2. Fetch Data using SodaPy
3. Pre-Processing
    - 3.1. Add Month, and Year
    - 3.2. Rename Fields
4. Create database, and send data to table
5. Visualizations


    ## 1. Import Libaries

st.write("The first thing that needs to be done is import the necessary libraries")

code = '''def hello():
    print("Hello, Streamlit!")'''

st.code(code, language='python')

            - OS: Built-in python package that interacts with your computer operating system.
            - [Pandas](): World-class python package that is used for data manipulation, and visualization.
            - [Seaborn](): Built on MatPlotLib, is provides for the creation of attractive, and informative graphs.
            - [Numpy](): Python library that provides powerful, and versitile array mathmatical, and computational functions.
            - [Sodapy](): Allows the user to connect to government, non-profit, and NGO open data sources. 
            - [MatPlotLib](): Python library that creates informative, and interactive visualizations.


    ## 2. Fetch Data using SodaPy
  1. Streamlit 1.31.0
    Python 3.12.1

TypeError: โ€˜strโ€™ object is not callable


File "C:\Users\_____\AppData\Local\anaconda3\envs\streamlitenv\Lib\site-packages\streamlit\runtime\scriptrunner\", line 535, in _run_script
    exec(code, module.__dict__)File "C:\Users\_____\Desktop\Learning\Norfolk\", line 60, in <module>
    st.code(code, language='python')

Hey @StephenGrassia,

Thanks for sharing this question! Please check out our guidelines on posting in the forum and edit your post to format your code properly, so we can help you resolve your issue :slight_smile:

updated code format

The code you posted works for me after fixing the syntax error.

What did you do to fix it? I have tried everything. I even ran a code that was just the sample on the documentation page, and I still got the issue

I changed url = f' by url = "URL".

I didnโ€™t have a problem with the url. Itโ€™s โ€œst.codeโ€

import streamlit as st             

code = '''def hello():
    print("Hello, Streamlit!")'''
st.code(code, language='python')

I even tried just this, and I am still getting the above error

Because you are not running the same code that you posted here.

Did you try restarting the app?

I had to remove the url from the initial response because it said new users canโ€™t post more than 5 urls. So I just removed all of them

I am going to restart my desktop to see if that works. If not, then its probably my set up. Idk, I just started using StreamLit a few days ago. Thanks for the quick responses. I appreciate it