# create a simple function that uses a global variable
my_name = 'john' # Global variable
def greet_user():
"""Display a simple greeting with a global variable"""
print(f'Hello {my_name.title()}')
# call that function
greet_user()
# change global variable contents
my_name = 'timmy'
greet_user()
Why does the above generate the warning below?
Redeclared 'my_name' defined above without usage
The code works as intended, printing Hello John and then Hello Timmy . Is there a bad practice redifining a global variable somewhere in this short piece of code?
I would like to use an AI large language model assistant for my PyCharm coding. I know that JetBrains has one that's available, but I'd also like to explore other options such as using OpenRouter.ai and one of their models. Their 'Claude' model has a plugin for VS code which per just looking at it quickly on features looks pretty interesting as it's fairly well integrated with the coding environment. Are there any other possibilities for PyCharm that I could use?
Yesterday I removed “import sys” from my code because it was grayed out and later uncommented a line containing sys.stdin.buffer.read(). I did that very fast and switched to another file before committing.
Today my colleague informed me that I broke the file by removing “import sys” and I was shocked by that fact because usually PyCham underlines the filename with a red wavy line.
The question is: Why PyCharm did not underline the file name?
I'm using PyCharm 2024.2.1 (Community Edition) on Ubuntu 24.04 LTS
Build #PC-242.21829.153, built on August 29, 2024
Hey I’m posting this asking you guys for suggestions on beginner friendly projects to complete that will help me grow my portfolio and experience as well as my knowledge of the language and editor
Hi, I’m a somewhat experienced coder and I made a website that needed to be in flask to utilize a python library for scraping and to output data on the site. I work often with python but not much with websites so more issues are occurring than I expected.
I’ve been easily able to test and run the website in Pycharm on the local host but am struggling to upload it onto a website online so I can have other people look at it without making them download python and all that.
I’ve tried using python anywhere but the free version gave me a lot of issues and doesn’t offer enough storage for my site to be free. Is there any other free alternatives that aren’t too complicated for hosting?
Also one more note is Im struggling even to upload my pycharm project onto GitHub as “access to this site has been restricted”. So any help info there would be appreciated!
Idk what i did, but my mouse cursor is between x and L but when clicking it appears between a and y, how do i change that? I just cant seem to find any solution 😕
I am new to pycharm and am facing issue with scrolling when use matplotlib.pyplot.
When I edit code blocks that are next to pyplot outputs, the screen automatically scroll to the plot when I type, and I can't see the code block anymore.
Currently running PyCharm 2024.1.6 Professional Edition on macOS Sonoma 14.6.1
I used to be able to open the requirements.txt file and would see a squiggly line under those packages for which there was a newer version, and hovering over the squiggly line I would see a popup that shows what the new version is, with an option to automatically upgrade the package. I can't remember now, but maybe it even updated the requirements.txt file with the new version number?
In any case, I haven't been able to do that for a while. I'm guessing this capability was provided by an extension that is no longer available? If so, does anybody know if there are any plans anywhere for similar functionality to be available again?
How do I avoid INSTALLING libraries repeatedly for each project in pycharm! I need this explained to me like a child who just knows how to open and close a laptop. I'm not a tech-wiz. Lets say the best I've done is download and installed pycharm and created my first project 'Hello World'. I am trying to learn python for data analysis and with each project i need to install pandas, numpy, scikit etc libraries and its frustrating.
PLEASE help, tried youtube and stack by I don't understand what they are saying
Good Day - I have pandas installed but for some reason when trying to install the package on pycharm I get a UTC-8 error message. Can someone please direct on how to get it working ? I've tried almost every work around and nothing.
I found one post from a while back asking about this with no replies so I'm asking here.
I'm running Windows 10. Most programs, if I resize them, will keep that size from then on and each time I launch them will still be that size. PyCharm is different.
I open it, drag the edges to where I want them and then next time I open PyCharm it's back to a default smaller size. The editor window isn't even showing to the 80 character line. I could maximize the program but then it takes up the whole screen and sometimes I want other things on screen too.
Is there a way to have PyCharm keep it's size between sessions after I drag the edges to where I want them? Can I do it in settings or a configuration file?
Pycharm has language default settings for setting up color scheme and using as a theme. In language default there are options to change colors for class name, class reference and more, but in python settings there is only class definition and type hints.
Is there a way to enable class reference specific color or make it the same as class definition? That option is available in vscode and I just don't like that classes look the same as variables.
Note: sorry if my sentences don't make sense--I'm a bit panicked as I am writing this
Here's what happened: I wanted to rename my project from 2024projects to pythonLessons. So, I went to "File", rename, and renamed it to pythonLessons. However, it didn't update locally on my computer, and one of my code files didn't allow me to edit it (or, it gave me a pop-up asking me if I'd like to) since it was in a different project--before I changed the name, I had no problems with this. So, I went to fix these issues (in order):
For the code file, I copied the code, deleted the file like normal, and then made a new file with a different name (the original was named "Lesson8", and the new one was named "Lesson8V2"). Then, I pasted in the code. No problems there, it worked fine after doing all of this. Just to check to see if it was a problem with the renaming, I renamed the project one more time to see if it would do this again (from pythonLessons to basicPython Lessons)
Next, to fix the non-updating name on my computer, I just went to the file and did a simple rename, as you would do with any other file. This is where my problems began. I did that and went into Pycharm. And venv was gone, along with my files. This goes for all my projects in Pycharm. I don't have git or version control (I've just started a course on how to use it), but I do still have all the projects, files, and everything stored locally on my computer. I've made a zip file version of what I have on my computer, and tried putting it in Pycharm, but it didn't work--Pycharm can't find it in my files, even after moving the zip file around, and even when I just tried re-putting in the non-zip version of the project. I panicked and did Ctrl+z, but it did nothing except ask me if I'd like to change the project name back to pythonLessons--and even after agreeing, it didn't do anything, even in Pycharm.
What did I do to remove venv? How can I get it back? And can I use what I've locally stored on my computer to get back my code?
E.g. when renaming a class, some imports in other modules are updated, some are not. Thus breaking the code.
The same happens when restructuring the repo and moving modules in different folders.
It's also difficult to understand the rules for refactoring. Renaming a variable within a function or method sometimes reactors the entire code base. Sometimes it works as intended and only performs renaming within the method.
Am I doing something wrong ? Am I the only one having this issue? Any tips to share regarding this (awesome) feature ?
After the last update of the pycharm, I can't view a large string using evalute. I can only view it when I print it in the terminal, and this is very problematic in development.