Search code examples
pycharm

How does one prevent Pycharm from recognizing installed packages?


How does one modify or curtail the pycharm python3 project search path such that it does not think my local project, when installed in the interpreter via pip (for example) is part of the project in pycharm?


Solution

  • You can create a virtual environment in PyCharm which inherits from the base interpreter, includes all of the packages included in that interpreter, then delete the packages in your local virtual environment without affecting the base interpreter. Obviously if you are working on a team that needs to also run, there might be issues with them using the base interpreter so you might have to create a team environment. (Also, I'd recommend not having privileges to the base interpreter when you delete things out of your virtual environment... just to be safe)

    Setting | Project: | Python Interpreter | Gear wheel (on the same line as Python Interpreter:) | Add

    Location: (Choose the location of your virtual env.) | Base Interpreter (Choose the interpreter which has things you don't like) | Check 'Inherit global site-packages' | Optionally check 'Make available to all projects' depending on your development practices -> OK

    After a couple of seconds you should have a new virtual environment that you can access via PyCharm. Click on the package you don't like and hit the - button. This should delete it only from your local environment and not the global environment (But.. Maybe test before trusting strangers on the internet)


    Side bar: Personally if a-lot of people want to develop poorly, it doesn't really bother me if the PyCharm team wants to help support them. I just hope I don't end up on a team that does that