How to hard reinstall PyCharm and Python? - python

I have been using Python with PyCharm with virtual environments and GitHub and there has been a lot of trial and error. I want to start fresh. I uninstalled Python and PyCharm with Windows's remove apps.
When uninstalling PyCharm I clicked option to delete everything there was to delete. Then I reinstalled restarted Windows and installed Python again and then PyCharm. When I launched PyCharm everything was exactly the same as before: same projects, same interpreters / virtual environments, same dependencies and same git capabilities.
I would really like to start fresh since now I have at least some more knowledge of these things, but can't seem to do so. I am not worried about losing my projects since the important ones are on GitHub.

You will have to manually delete a few directories used by the IDE and individual projects. This is an important fail-safe so you don't lose all your work and configurations should you need to reinstall PyCharm or uninstall it by mistake.
See the documentation:
Directories used by the IDE
By default, PyCharm stores user-specific files for each IDE instance (configuration, caches, plugins, logs, and so on) in the user's home directory. However, you can change the location for storing those files, if necessary.
This JetBrains blog post is also worth considering Directories used by the IDE to store settings, caches, plugins and logs.
For example,
same interpreters / virtual environments
An interpreter is just a directory with a Python executable and installed libraries. Although the PyCharm IDE can index and keep track of your interpreters they are independent and you'll have to delete them separately when needed.
same projects
Each individual project contains a directory called .idea where the IDE settings for that project are stored. You can delete the .idea directory and keep the source code.

Related

What are the External Libraries in a PyCharm project?

I'm a bit confused on this and can't find a satisfactory answer searching elsewhere - everything is about using external libraries in some way or another.
In my PyCharm projects, I've got your project root directory, which contains a venv. This venv of course contains the python executable relative to the project, as well as the relevant site-packages and modules I've downloaded via pip or whatever.
But there's always an External Libraries section, that has it's own Python executable, venv, .gitignore, site-packages, etc.
Is this normal? What's the purpose of having two venvs in the same project?
Thanks!
You only have one venv normally in your Project
The other Python Executable should be the global one.
Normally you use a venv to keep track of the needed Packages for this specific project. So that you don't confuse other Packages with other projects or have dependency/Version Issues
If you want you can also use the global Installation of Python which would not create a venv

VSCode and Anaconda Environments: How to have dev extensions/environment and my code under development use different Anaconda environments

In VS Code, many extensions, such as Tab Nine and Lint, rely on specific Python packages to function. On the other hand, the code I develop may need a different set of packages. Because there is the potential for package conflict and because we want the environment that we develop code to mimic the production environment, it is convenient to have the dev environment/extensions use one Anaconda Environment and the code I develop to use a different Anaconda Environment. But I am not sure how to configure this. Can someone help?
Down in the bottom left corner of VS code you can manually select the python environment depending on which codebase you are working with. The selection can be saved in the settings.json file so you don't have to manually reselect each time.

Python not showing existing venv in interpreter select

I have a shared flask web project I am working on with 2 other developers, one of the developers initialized the venv on his pc, uploaded his project structure to github from where I cloned his repo.
Now I when I start vscode and open the project folder, python does not auto detect the venv and asks if it should set is as the interpreter, the only option I have is the default system wide python install, and not the venv python interpreter.
I tried adding it to the list by using the command python:select interpreter and then finding the python.exe inside the venv/scripts folder, but this does not work and vscode still asks for a interpreter.
I also tried manually adding it inside of my workspace settings.json file like so
"python.pythonPath": "C:\\laragon\\www\\Proftaak\\venv\\Scripts\\python.exe"/
But vscode also gives an error on this saying the interpreter is not valid.
How would I fix this?
This is not expected to work as virtual environments are not designed or meant to be movable. They are meant to be created on each machine you need a virtual environment on. As such, I suspect that the virtual environment does not work outside of VS Code which could prevent it from selecting it as a possible working environment.

How to export the environment of Python project

I am using Pycharm Community Edition 2019.2.. I imported a Python project from another computer. I just copied the files and then created a new project the directory. There are multiple modules that are imported in this project that I have not installed on my computer. I want to know what is the best way to automatically manage all the dependencies of this project.
I created a virtual environment(venv) in the original project. Can you export this somehow? Is this even the right path to solve this problem? The virtual is supposed to manage dependencies, though I haven't read anything about exporting settings, it mostly about isolating dependencies and settings. I've been looking at conda and pipenv as well, but I focusing on virtual environment before I try to go laterally in problem solving.

IntelliJ + Python plugin: Python remote interpreter gets created without classpath, does not work

When I create a new remote Python interpreter, IntelliJ doesn't find any dependencies to my code and doesn't seem to index any libraries. Most of the code is red. I think I've pinpointed that to the "classpath" being completely empty, which is unlike some other Python SDKs that I have added (local ones). Some of the times I am able to get it to populate the classpath with paths pointing to the IntelliJ Caches directory by clicking around in the interface, but I most of the times it does not work and I cannot reproduce how to make it work. How do I make sure the classpath gets populated correctly?
I am using IntelliJ Ultimate version 2016.2.1. with the Python plugin version 2016.2.162.43. I am developing on a Vagrant virtual machine and I'm adding a Python remote interpreter that is inside a virtual environment (venv) inside the virtual machine. When I add the remote interpreter, I use:
On the SDKs tab - the + button.
Python SDK
Add Remote
I select the Vagrant option
Point it to my Vagrant project directory.
Point it to the python3.5 executable inside my virtualenv
Add the SDK
Then the classpath looks like this: https://www.dropbox.com/s/3xbzopb4y9bhn0u/Screenshot%202016-08-11%2017.19.43.png?dl=0 and IntelliJ doesn't recognize any libraries/builtins. For other SDKs, the classpath contains several entries with remote_sources, python_stubs or python-skeletons in the name and they work.
As a workaround, I copied every entry from the local python interpreter classpath to the remote one and everything seems to work
Edit:
Actually, I don't know what triggered it, but some days after I wrote this, I noticed that IDEA started downloading source files from the server. I went to the interpreter settings, and the classpath entries I had manually added were gone and replaced by "system/remote_resources" entries. I think this is how it's supposed to work, but unfortunately I don't why I didn't work from the start nor how to trigger the correct behavior, it just started working on its own.
While this issue is a bit older, I had the same issue today with IntelliJ IDEA 2021.2.
I was able to solve this by using Navigate -> Search Everywhere -> Type interpreter -> Select Rescan Available Python Modules and Packages.
This prompted downloading of the remote resources and indexing. Afterwards, the classpaths were filled in properly.

Categories