Warning – variable referenced before assignment

Having the following snippet: I get a Pycharm warning Local variable cache_data might be used before assignment. Could you please explain how this could possibly happen in this case or is this an inspection bug? Answer Unfortunately this seems to be a known issue in PyCharm that was reported back in Nov 2019. It seems the inspection code added to handle assignment expressions doesn’t recognise that the code inside this conditional can only be reached after setting the local variable. The report notes that it also occurs in comprehension conditionals, and there doesn’t seem to be any fix currently available

Running two files on a single project on PyCharm

I am currently developing a IoT sensor value simulator using the PyCharm IDE (along with pygame). Essentially, I am trying to produce/send data to Microsoft Azure IoT platform while there is a GUI available for users, in which they can see the temperatures of each sensor, change the sensor outputs, etc. Since I do not want to spam Azure with messages, I use sleep function between every messages sent to limit the rate of messages being sent. As a result, this slows down the whole application and it is a bit cumbersome. Is there a way to get around this

CuDNN crash in TF 2.x after many epochs of training

I’m currently becoming more and more desperate concerning my tensorflow project. It took many hours installing tensorflow until I figured out that PyCharm, Python 3.7 and TF 2.x are somehow not compatible. Now it is running, but I get a really unspecific CuDNN error after many epochs of training. Do you know if my code is wrong or if there is e.g. an installation error? Could you please hint me a direction? I also didn’t find anything specific with searching. My setup [in brackets what I also tried]: HW: i7-4790K, 32 GB RAM and GeForce 2070 Super 8GB OS: Windows

PyCharm Interpreter configuration error, code example with Neo4j with Python Driver

I started a local neo4j server and work with it using Python (PyCharm) Installed with (python -m pip install –upgrade neo4j==4.0.0) Python 3.8 Neo4j 4.0 But when the program starts, it returns an error. What to do? How can I fix this? Answer Probably you have wrong PyCharm Interpreter configuration and/or Run Configuration. Try running code with console command from Terminal, not from PyCharm.

pycharm python selenium scraper apparently not printing correct value

I new to python, selenium, pycharm and such. I’m trying to print the value of a on a website ( at the moment of writing this the value is 6320 ).The code is not giving errors but it’s printing nothing. As you can see in the screenshot, when i’m debugging and hovering over the variable, it’s displaying 6320, which is the value i’m looking for. What am I doing wrong? Thanks a lot for your help! Answer You need wait until .visibility_of_element_located and use this xpath: //td[contains(., “Total*”)]//span[last()], although your xpath also works, but it is an absolute xpath that

Writing Arabic in Pycharm console

In PyCharm I have no problem in printing Arabic in the console, but the problem that I can’t write in Arabic. Instead it is written as weird symbols. How can I fix it? Answer It’s likely that you’re using some weird encoding, try to change your file encoding to UTF-8 or UTF-16: more info: https://blog.jetbrains.com/idea/2013/03/use-the-utf-8-luke-file-encodings-in-intellij-idea/   If that doesn’t work it’s also possible that your current font doesn’t support those characters. Try to use some other font. The editor font can be changed from the preferences:

Run / Debug a Django application’s UnitTests from the mouse right click context menu in PyCharm Community Edition?

I must emphasize on PyCharm Community Edition which does not have any Django integration (v2016.3.2 at question time). I’ve Googled my problem and (surprisingly,) I did not get any answers, (of course I don’t exclude the possibility that there might be some, be but I just missed them). The question is simple: in PyCharm, one can Run (Debug) an Unit Test (TestCase or one of its methods) with a simple mouse right click (from the context menu) just as in the image below: Unfortunately, that yields an exception: Note: I only added the question to provide an answer that might

PyCharm noinspection for whole file?

Is it possible to disable an inspection for the whole file in PyCharm? The reason this is needed is when dealing with py.test. It uses fixtures which appear to shadow function parameters, and at the same time cause unresolved references. e.g.: There is also other warnings from py.test, such as using pytest.raises() causes a “Can not find reference ‘raises’” in pytest.py. Maybe there’s another way to fix these problems? Maybe I’m using py.test incorrectly? Answer Is it possible to disable an inspection for the whole file in PyCharm? Yes. This answer is for this question only (and not about “Maybe

How do you set up Pycharm to debug a Fabric fabfile on Windows?

Is is possible to set up Pycharm to step through a a Fabric fabfile.py? It seems like this would be doable with the run/debug configuration editor but I can’t seem to get the settings just right. The editor is asking for a script to run and I’ve tried the fab-script.py file it is just giving me the fab help options. It seems like I’m close but not quite there. Answer Here is how I ended up setting this up in case this is useful for someone else. As with most things like this, once you know the magic settings, it

In PyCharm, how to navigate to the top of the file?

I’m new to PyCharm and haven’t been able to figure out what I’m sure is a very simple thing — what’s the key stroke to go to the top of the current file? (Bonus question — is there a way to scroll to the top of the current file without moving the cursor there also, a la the Home key in Sublime Text 2?) Answer You navigate to the top of the file using Ctrl+Home. It moves cursor too. So does navigating via Page Up and Page Down keys. Ctrl+Up and Ctrl+Down move the view without moving cursor but scrolling