Pycharm error: module must not be null?
Hi all
I am getting this error on my pycharm community addition:
Build #PC-222.4345.23, built on October 10, 2022
Runtime version: 17.0.4.1+7-b469.62 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
It is a simple python web scraping script but it won't run.
Below is the error and my run config:
This is my code, it runs on my ubuntu laptop with pycharm: https://github.com/jzoudavy/webScrap_Selenium/blob/main/test.py
I am not sure what's missing here.
Thanks
Error running 'test': Argument for @NotNull parameter 'module' of com/intellij/openapi/roots/ModuleRootManager.getInstance must not be null
Please sign in to leave a comment.
hi can someone approve this post pls?
issue resolved by restarting pycharm
I am getting the same error trying to run a python script in IntelliJ. Restarting IntelliJ did not resolve the issue.
I was able to fix this by switching to a different python interpreter in my run configuration which could run the desired script, running the script, and then switching back to the original python interpreter. I have no idea why that worked
Hi,
Can someone please provide steps to reproduce the issue or a code sample? The link from the first post is not working anymore.
I had the same problem, i resolved it : Go on Run -> edit configuration -> on the right side find where is "paramaters" and fill it by one of the options given by Pycharm This is how it looks like
You need to select the execution method ( you can select 1st option). else the tool doesn't know where to get this executed.
Thanks @Vivek, setting `Run with Python Console` worked for me. `Emulate terminal in output console` gave the same error.
I'm a little worried because this configuration was unchanged from when it worked on a previous version, and I've had errors using `Run with Python Console` in combination with the debugger before. Anyway, short term, problem solved.
This worked for me:
Go on Run -> edit configuration, Changing Python interpreter from Use specified interpreter -> Use SDK of this module.
I too have just run into this issue. Was working fine on Friday, signed back in on Monday, and now I am seeing the error in the original post.
Got this error after `git switch --orphan <branch_name>` reindexing whole project and checking "emulate terminal in output console" helped
Have same problem when moving to CE version and import settings from Pro version.
Just delete problems configurations in "Run/Debug Configuration" window and start them again from context menu.
Saw the same issue, but only when trying to debug.
Soved the problem removing the configuration and creating a new one. Menu, Run, Edit Config. Delete/Add again.
Go to Run -> Edit Configuration. Click the script dropdown menu and select module if not selected. Then press Ctrl + Space to see the Code completion options.
Plenty of options will pop up. I selected “__main__” and it fixed the issue for me.
I had this issue, in my case it's because I was sharing the run configuration between two repos and had to fix the module_name in the xml run configuration file
In my case the solution was to delete all of the run/debug configurations and create new ones, something got messed up with the tool's internal representation of all previously working run configs after merging branches and using PyCharm's “Invalidating Caches”.
For me this error occured when I renamed an existing project to something else.
The solution: go into .idea folder in your project and make sure that the misc.xml and <your-project-name>.iml files actually have the same name as your project.
it works for me that delete all run configure and regenerated it automatically
This is happening now continually for me. v2023.3.2 on both Mac and Windows.
None of the above suggestions works - I've had to switch to Visual Studio Code to gain debugging functionality again until this is resolved. :-(
Why doesn't PyCharm allow logging of this direct from the IDE to Jetbrains?
Ed Burke , would you please share logs from Help | Collect Logs and Diagnostic Data? What are the steps to reproduce the issue?
Having this problem too with an existing project working till now. Problem arises when I clone this project again from git so I cannot make a fresh start and I am tied to a single old git checkout :(. It happens on Linux and Windows with this repo. It does not happen with new empty projects unrelated to my repo.
Touching debug config as I saw in other comments did not help.
I diffed directory tree from not working copy and working copies and found some difference in .idea\misc.xml that I copied but it did not help.
Not sure hat to do now.
I can provide extra info if requested. Help | Collect Logs and Diagnostic Data creates a file I could provide.
Hi txemi ,
Please upload the logs to https://uploads.services.jetbrains.com and let me know the upload ID.
Is this git repo public? Can you share it as well?
The repo is private.
I think I found simple workaround for me. I will try to explain:
- This happens when I create debug configurations before python interpreter has been configured itself for the project, so for me worked deleting debug configs and create them again, for instance trying to debug some python file in the project.
- The origin of the problem for me is a usability issue: when you create in pycharm a new project from scratch pycharm gently offers you to download the version you choose of the python interpreter and everything goes well onwards.
- When you clone a project from Pycharm Pycharm allows you debugging files in the project failing in the process because of not existing python interpreted configured instead of offering to download one like in “new project” case or at least suggesting better hint to user. In fact I go little crazy trying to find download option in this situation. This wrong configurations created persist for later problems.
- For me all debug configurations created before python interpreted is configured throw the problem mentioned before. So solving the problem was as easy as deleting them and creating them again after having python interpreted configured.
Thanks,
I have hit this now and again, and think that it might be triggered by setting a project name that includes a “/”.
For example I changed a project name from “feature” (the directory name) to “WT-354/feature” (the last two components of the directory path) and this worked… and then it stopped working.
When I looked in .idea, I saw a WT-354 subdirectory containing feature.iml, and workspace.xml had lots of <module name="WT-354/feature" /> lines.
Removing the WT-354 subdirectory and changing these workspace.xml lines to <module name="feature" /> fixed the problem.
These projects seem to retain their new names, but I don't know where they're stored! I don't see them anywhere in .idea.
Might this provide a clue to the initial problem?
I had this issue and had the .run.xml files stored in the project.
When i set up the project again i got this issue because before i renamed the project.. The new folder name becomes the module name.. So when i renamed the project again to the old name the scripts did work again.
Well this still creeps up even with the latest and greates of 2024. It should not happen just because a project is being renamed, or due to a run configuration being part of the project (under .run or otherwise). Basically, my solution is to update all occurences of the old project name in all files under .idea, give or take having to redo the project settings (content root and project interpreter). this might not always work.