I am having this extremely weird issue with restoring a pycharm project in pycharm 5 on windows. Originally all I wanted to do is make it so the project does not appear at the start selection, but ultimately that command has translated into something else.
So far I have checked my recycle bin and used recuva but it's no where to be found. Is there some type of default in the pycharm that disables this behavior and if it possible to get my projects back?
If you've cleared your recent projects you'll need to locate the folder where you saved your project.
Pycharm stores the individual project config files in a .idea directory in the project root, then further files for the general app config in Windows are stored in;
<User home>\.PyCharmXX\config that contains user-specific settings.
<User home>\.PyCharmXX\system that stores PyCharm data caches.
To open your project again, you'll need to point Pycharm's 'open project' dialog to the directory containing the .idea folder, so if you can't remember where you saved the project, I'd suggest running a search for .idea, remembering that it will likely be a hidden folder.
See the docs on the application data
Related
My home dir ran out of space and I wanted to move the PyCharm project to another directory. I ended up copying it because refactoring didn't work. I deleted the pycache and the zip exception, that had appeared was gone and now everything works as expected. I still use the venv location of my initial project location though, from what I can see in settings/python-interpreter.
Is there anything wrong with this procedure, anything I'm not aware of?
Should I edit some of the files in the .idea folder?
The $PROJECT_DIR$ variable caught my attention, but I couldn't find where this variable is actually set.
A clean way to move your project is right-clicking on your project folder in "Project view" (Alt +1 ) , choosing Refactor and then Move Directory.
The $PROJECT_DIR$ variable is dynamic and taken from the directory your project is in, so that isn't a problem
Your .idea folder should be recreated by PyCharm even if you completely delete it. However I wouldn't advise deleting your folder mainly because you will loose your project-level dictionary (wordlist).
Invalidating caches has a wider impact because it will clear IDE wide settings not just project specific settings. (It's mostly useful if your cache becomes outdated, which tends to manifest itself by inexplicable errors.)
If something goes wrong just open the moved directory as a new project going to File > Open. For a simple project there are 2 main settings that you should check and may have to adjust:
In settings "Settings" (Ctrl + Alt + S) go to Project: your_project_name and there check that Project Structure makes sense and retains your configurations.
In Run > Edit Configurations make sure that Script path and Working directory are set to the locations you want.
Is there anything wrong with this procedure, anything I'm not aware of?
From your description you took the right steps since refactor didn't work, just ensure the above configurations are met and if the IDE doesn't issue any errors you should be good.
Should I edit some of the files in the .idea folder?
This would rarely be necessary and is generally discouraged. The files in the .idea are IDE generated and should not be touched. Any necessary changes should be made using the IDE graphical interface to set configurations (which means you don't have to worry about the contents of .idea).
I'm using macOS 10.15.4 and PyCharm 2019.3.4
I currently have a folder inside the PyCharmProjects folder (that is automatically created when PyCharm first runs) where I keep projects for a class. I want to move this folder, which contains multiple other folders which each contain PyCharm projects, somewhere else on my computer (like the Desktop). The problem is if I move the folder (or even just a single PyCharm project) the next time I open the project in PyCharm, it says "Invalid python interpreter selected for the project." Now I can manually go into PyCharm preferences and point it to the new location I moved the folder so it can use the correct python interpreter. But this would be tedious to do for every single project I have. (And yes, every project I have uses its own interpreter and virtual environment.)
Is then a way I can move a folder containing multiple PyCharm projects without loosing the references to each of their respective python interpreters?
(Feel free to reword this question or the title.)
PyCharm uses configurations from your home directory. The docs say
macOS
Configuration
~/Library/Preferences/<PRODUCT><VERSION>
Caches
~/Library/Caches/<PRODUCT><VERSION>
Plugins
~/Library/Application Support/<PRODUCT><VERSION>
Logs
~/Library/Logs/<PRODUCT><VERSION>
where <PRODUCT> is PyCharm.
They are xml files. Among them also a list of configured interpreters. They are separate because they are available for all your projects to be chosen as the default interpreter. You'll have to edit the xml files.
For some reason PyCharm does not help with a moved virtualenv directory directly. (see comment from engineer: https://youtrack.jetbrains.com/issue/PY-32435#focus=Comments-27-3139072.0-0)
On the upside, everything else seems to work, except the path to the venv python. That one can be changed through preferences/project preferences/python interpreter. Just click on "add", "existing", and select the python compiler in your project folder.
Try not to select the ".virtualenvs" python compiler, as if you fumble like I did, it seems it's a bit of a pain to get rid of it and go back to the right one. If you do that, renaming the project folder once more gets you back to square one and you get to try again.
Note that I'm using MacOS. YMMV.
How can I change the default directory in Spyder when opening a project via Projects > Open Project? Spyder seems to open always the same directory: User Home directory.
Most of my projects are located in one directory, which is not my home directory. I save there also the copied projects. It would save a few clicks to open a project. In particular, it is nice to have because the number of Recent Projects is limited to 10.
I tried to change Preferences > Current working directory > the following directory, but this does not have any impact on the Open Project directory.
Is there a possibility to change it either in GUI, or via configuration files, or registry (without changing the user home directory of course)?
I put a shortcut in my home directory called _shortcut_to_spyder_projects to get to my projects faster. The leading _ keeps it at the top of the list.
I have a PyCharm project on my Windows, where I am able to run most .py files by pressing Ctrl + Shift + F10 (or running the debugger). In one of the files however I get the error
Error running 'test':
Cannot run program "\opt\anaconda\bin\python" (in directory "..."): CreateProcess error=2, the system cannot find the file specified.`
The test.py file right now only contains print('hello')
I can do this for the other files, and using 'Execute selection in console' also works fine. Given I am on a Windows machine the "\opt\anaconda\bin\python" part looks suspicious, but I don't know how to fix it.
Any help?
Copying the content to another file (e.g. test_2.py) 'fixes' the problem, but since this is a collaborative project this isn't viable.
I think your case is cause by some project environment has changed.
I suggest your open the workspace.xml which located in .idea\, check the parameters in it.
or you can delete the directory ".idea" and re-create the project locate in the original path.
Hope it work
I had the same problem in PyCharm IDE and Windows after adding new libraries and some changes.
I recreated Run/Debug Configurations with these steps (Instead of recreating the whole of project!):
Select Edit Configurations... from top panel in PyCharm IDE
Select these files and press delete for deleting them
Recreate these files likes this images:
Click green arrow or press Ctrl + Shift + F10
This is what I had to do:
Check the .idea/workspace.xml for any old venv references (there are several tags like "SDK_HOME" which store the path to the venv) and update as necessary
Check the .idea/RunConfigurations for any run configs and update them (or delete and recreate as you like)
when I installed the pycharm I had the same issue. for this, you really need to understand the concept of the virtual environment. this error comes because you run the file in another directory in which you do not create any virtual environment.
let's say you create a virtual environment in any folder located at the desktop now you run the files in any other folder located in /user/AppData/any_folder then it will show the error that the system can't find the file specified.
So be sure you run in a file in the same folder in which you created a virtual environment.
I had the same problem after downloading a project from Github. It ended up being a configuration problem.
Creating a new project on Pycharm, pasting the code in it, and using your own configuration should solve the problem.
I've create a pydev project in eclipse.
At the top level of my workspace I can see these two files:
.project
.pydevproject
I can also see these in each of my subfolders that contain my actual projects.
At the top of my workspace there is also a
.metadata. folder.
What should I commit to source control?
Ie what can I delete and still be able to open the project with minimal effort (hopefully entirely automated regeneration of files)? If this was Visual Studios C++ project the answer would be to keep just the ".sln", "vcxproj" and "vcxproj.filters" because the "vs" folder and "suo" files will autogenerate on openning. I've tried to delete the ".metadata" folder, but after that nothing appears to load in my workspace.
Also, I am working with someone not using an IDE. What eclipse files do we need to update to keep in sync?
Disclaimer: I am not familiar with PyDev, just with Eclipse in general. You definitely should not check in the .metadata folder. That one is for your Eclipse workspace as a whole and contains your personal configuration. (That's why your workspace appeared empty after you deleted that folder.) In fact, you should not check in your workspace folder at all, but just the several project folders within it.
Whether to check in the .project files is sort of a matter of taste. Those contain project specific information and settings and with those its easier to import the project into Eclipse, but you can import the project without those, too, it's just a bit more work. If other developers are not using Eclipse, those are useless for them. In the worst case, your co-developers will delete those files from source control and when you update your project later, they are deleted on your end, too, messing up your project.
About deleting the files: Note that there is a difference between not checking files into version control and deleting them locally. So in short: Do not commit those files into version control, but don't delete them locally, either. Depending on what sort of version control you are using, you can set it to ignore those files.