If that's the only code you have then, yes, you set (for example) q1 to a value but never use it after that.

If you've failed to show us code outside of those functions that uses q1, it still is not being used.

That's because, if you assign to a variable (like q1 = 42) within a function and that variable is not explicitly marked global, it will be a new local variable within the function, not one already existing in a containing namespace.

Answer from paxdiablo on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › variable is not accessed pylance (visual studio code)
r/learnpython on Reddit: Variable is not accessed pylance (Visual Studio Code)
December 24, 2021 -

So as part of a book I'm working through I'm trying to plot weather data using two different csv files and have implemented a function to do so.

import csv
from matplotlib import pyplot as plt

def get_high(filename, highs):
    with open(filename) as f:
        reader = csv.reader(f)
        header_row = next(reader)

        for row in reader:
            high = int(row[4])
            highs.append(high)

highs = []
get_high('report1.csv', highs)
fig = plt.figure(dpi=128, figsize=(15,9))
plt.plot(highs, c='red')

highs = []
get_high('report2.csv', highs)

plt.plot(highs, c='blue')

plt.title("January Tempatures in Miami 2020(red) vs 1970(blue)", fontsize=20)
plt.xlabel("Days", fontsize=10)
plt.ylabel('Tempatures (F)', fontsize=10)
plt.tick_params(axis='both', major='which', labelsize=16)
plt.show()

When I run this it gives me "high = int(row[4]) IndexError: list index out of range".

I've tried going back and changing 4. At 0 and 1 it tells me "ValueError: invalid literal for int() with base 10:" And as soon as I hit the 2nd index (where the integers start) it gives me the IndexError. I noticed when I hover over header_row it tells me that it can't be accessed and I think that's what's causing this problem but I can't find a fix for it.

EDIT; Also looking for a way to make it so the graph DOESN'T start mapping at 0.

Discussions

"<module_name>" is not accessed Pylance warning when using Conda
I'm getting " "is not accessed warnings from Pylance in my python file while importing all the stdlib modules. The warning description just says: conda_env_location/... More on github.com
🌐 github.com
3
3
December 1, 2023
Incorrect "variable is not accessed" messages
Environment data Language Server version: v2020.12.1 OS and version: Mac OS Mojave 10.14.6 Python version: 3.7.5 with pyenv Expected behaviour When a variable is passed to a function/method that Pylance couldn't introspect (sometimes it'... More on github.com
🌐 github.com
4
December 11, 2020
'module' is not Accessed Pylance(Pylance is greyed out)
When I am importing the python module 'requests'. PyLance or VSCode underlines it with yellow meaning warning. It is also shown in the problems panel in the integrated terminal of vscode. H... More on github.com
🌐 github.com
51
December 21, 2020
"variable" is not accessed when it is used by `locals()`
Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.6 · Pylance should pick up that variables are accessed when locals() use them. More on github.com
🌐 github.com
2
October 19, 2020
🌐
GitHub
github.com › microsoft › pylance-release › issues › 107
False "variable is not accessed" message · Issue #107 · microsoft/pylance-release
July 14, 2020 - Variable msg in Test.func is marked as "string" is not accessed, while it is clearly being accessed in the next line. class Test: def func(self): try: 1 / 0 except ZeroDivisionError as exc: string = "A string" # pylance: "string" is not accessed raise exc(string) try: 1 / 0 except ZeroDivisionError as exc: string = "A string" # No pylance message here (?) raise exc(string)
Author   tweakimp
🌐
GitHub
github.com › microsoft › pylance-release › discussions › 5143
"<module_name>" is not accessed Pylance warning when using Conda · microsoft/pylance-release · Discussion #5143
December 1, 2023 - Having similar issue while I'm using a native Python interpreter (that is directly installed on my PC). In my case, I have a module transaction_manager.py that contains class TransactionManager. However, even if I've imported the module and instantiate an object of the class in the module, Pylance complains that the module is not accessed and the class is not defined.
Author   microsoft
🌐
GitHub
github.com › microsoft › pylance-release › issues › 719
Incorrect "variable is not accessed" messages · Issue #719 · microsoft/pylance-release
December 11, 2020 - It's grayed out with "variable is not used" message on hover. I think the best thing I can do here is to show an image of actual code. Stream.from_postgres_increment is a class method, but it's nowhere to be found in Stream class definition: it's actually loaded later on via entry_points mechanism. Pylance can't run introspection on it (and that's totally OK), but the problem is that it also counts all variables passed to this method as unused, while they are obviously used.
Author   roveo
🌐
GitHub
github.com › microsoft › pylance-release › issues › 757
'module' is not Accessed Pylance(Pylance is greyed out) · Issue #757 · microsoft/pylance-release
December 21, 2020 - When I am importing the python module 'requests'. PyLance or VSCode underlines it with yellow meaning warning. It is also shown in the problems panel in the integrated terminal of vscode. Hope it gets fixed soon. I did not use the Bug Re...
Author   pybash1
Find elsewhere
🌐
GitHub
github.com › microsoft › pylance-release › issues › 5567
False "is not accessed". · Issue #5567 · microsoft/pylance-release
March 2, 2024 - microsoft / pylance-release Public · Notifications · You must be signed in to change notification settings · Fork 1k · Star 2k · New issueCopy link · New issueCopy link · Closed · Closed · False "is not accessed".#5567 · Copy link · Assignees · Labels · by design · JingBinCN · opened · on Mar 2, 2024 · Issue body actions · Language Server version: v2024.2.2 · OS and version: Microsoft Windows [版本 10.0.19045.4046] Python version (& distribution if applicable, e.g.
Author   JingBinCN
🌐
GitHub
github.com › microsoft › pylance-release › issues › 4629
pylance does not recognize use of imported function in a Jupyter notebook cell that contains a %% command · Issue #4629 · microsoft/pylance-release
July 19, 2023 - Python version (& distribution if applicable, e.g. Anaconda): 3.9.16 (conda: 23.3.1) It is difficult to provide minimal, self-contained code here, as it relates to Jupyter Notebook cells. ... In this case, in 1st Jupyter notebook code cell function A will be greyed out and upon hovering over the greyed out A, I get the mesage: "A" is not accessed Pylance · Also in subsequent Jupyter notebook code cells, B is not recognized as a defined variable...
Author   gro1m
🌐
GitHub
github.com › microsoft › pylance-release › issues › 3225
False positive "variable/parameter/function is not accessed" warning · Issue #3225 · microsoft/pylance-release
August 21, 2022 - Python version (and distribution if applicable, e.g. Anaconda): ... Pylance started to warn that when I added a try/except structure into the for loop, the variables, the functions I imported, and the parameters I gave to the functions were not accessed.
Author   emrekara369
🌐
ProxiesAPI
proxiesapi.com › articles › troubleshooting-python-requests-not-recognized-by-pylance
Troubleshooting "python requests not recognized by pylance" | ProxiesAPI
February 3, 2024 - The root cause is that Pylance does not have full knowledge of the requests library when it analyzes your code. Pylance relies on stub files to determine what modules, functions, and variables are available.
🌐
Python.org
discuss.python.org › python help
"pyotp" is not accessed Pylance - Python Help - Discussions on Python.org
October 26, 2024 - Hello Friends, I have created virtual environment for my project and install a Module ‘pyotp’, but i am getting import error, ‘pyotp is not accessed Pylance’. please help in this
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › programming › python
Pylance: can import csv, but NOT sys OR os modules ... WTHey? - Raspberry Pi Forums
Time to go cmd line simple whilst I unravel vscode... Next thing I'd try is to uninstall the python and realated extensions (pylance, etc), close vscode, remove that folder ~/.vscode/extensions/<python ext dirs>, run vscode, reinstall the extensions and see if the issue goes away.
🌐
GitHub
github.com › microsoft › pylance-release › issues › 1120
Pylance "argument" is not accessed · Issue #1120 · microsoft/pylance-release
April 4, 2021 - Python version (and distribution if applicable, e.g. Anaconda): ... class GreeterBase: @staticmethod def greeting(name: str) -> str: ... # "name" is not accessed class HelloGreeter(GreeterBase): @staticmethod def greeting(name: str) -> str: return "Hello, %s!" % name
Author   pasunx
🌐
Reddit
reddit.com › r/vscode › [deleted by user]
Can anybody help me figure out why this variable is not ...
July 24, 2022 - It just launches a shell and sends the command to run your program with the system’s python installation. (It should be exactly the same as if you type the command into power shell manually). You might’ve accidentally changed something since the last time it worked. The pylance message is actually just a warning, telling you that the variable ‘p_pressed’ is assigned to but never used, meaning it doesn’t serve any purpose.
🌐
GitHub
github.com › microsoft › pylance-release › issues › 408
Variable "is not accessed" when using pandas query / eval · Issue #408 · microsoft/pylance-release
September 24, 2020 - I keep getting a "is not accessed" message for variables used in the Pandas or DataFrame "query" and "eval" methods using @variable inside the string. I.e. given a list "labels" and a column "label" in a DataFrame (X_train): X_train.query("label in @labels") gives me "'labels' is not accessed". Pylance: v2020.9.6 Python 3.8.3 64bit Windows ·
Author   akanz1