If I'm closing a project and then just delete the project folder, after PyCharm restarts an empty project folder is created again.
Just follow these steps in order. They assume you currently have the project open in a PyCharm window:
Close your project by clicking on File -> Close Project
Locate your project in the PyCharm file directory
Delete your project's directory
I agree that PyCharm's handling of what should be a very simple procedure is crappy. Maybe this will be improved in the future?
If you want to remove the project from the recent projects list, just highlight the project with your mouse and hit the del key.
This is for PyCharm 2019.1, but I can bet this will work in previous versions.
I am assuming you are in a Unix based operating system (macOs or any Linux distribution). I am also assuming you have currently opened the project you want to remove.
Close the project by going to File → Close Project:
Remove the project from Pycharm's Welcome Window:
Locate your project and delete it, you can use several alternatives, but I encourage you to use the following
$ rm -rf /path/to/your/project/directory
The previous command will work in macOS and Linux. In Windows, you can delete it manually by locating the projects directory using File Explorer.
That's it, the project has been completely deleted!
click the project you want to remove.
menu bar Edit-> Remove from Project View.
Version 2017.2.1
Press Alt+1 to bring the project pane, and make sure you're in
Project view (not Project Files view).
Select the desired project, and choose "Delete from project
view" from the context menu (right click). You can also use Delete
key.
There is a difference between PyCharm projects and the list of recently opened projects (File → Open recent...):
The PyCharm project is simply an arbitrary folder1 with the appropriate .idea subfolder in it.
The list of recently opened projects is simply the list of paths to some of such folders.
PyCharm does not keep the list of all projects, so you may safely delete a project folder (or its .idea subfolder) from your file system.
But if you have a bad luck, the path to your project directory is already listed in the list of recently opened projects, and if you try opening it with File → Open recent..., then
in older version of PyCharm, the deleted folder is re-created (as a new folder with only the .idea subfolder in it),
in newer versions of PyCharm you get the prompt similar as
The path C:\Users\you\PycharmProjects\deleted_project does not exist.
If it is on a removable or network drive, please make sure that the drive is
connected.
with buttons "OK" and "Remove From List", so you may simply remove the deleted folder from the list,
in all version of PyCharm, if you deleted only the .idea subfolder, it is silently re-created (but all your project settings are lost, of course).
To prevent from the uncomfortable consequence of the 1st possibility of using the File → Open recent... to re-create already deleted project, follow e.g. the first two instructions in the Simin Jie's answer.
1 generally a subfolder of the PyCharmProjects folder in your user profile directory (e.g. if you created it with File → New Project... and accepted the offered default path).
Works for Windows and MacOS.
File -- Open Recent -- Manage Projects
Cliek X to delete from Recent Projects
Delete local directory
According to https://www.youtube.com/watch?v=ksbmc0coO4k
In PyCharm 2018 I finally had to resort to deleting .idea folder and the project went away.
Highlight the project with your mouse and hit the del key, which works for me.
In 2021 maybe another way to do it. My problem was in project with user directory (root was /Users) that contains too many not Python files, and it triggers some problems with Git and file index.
What I did:
show hidden files (Cmd + Shift + .),
find .idea directories,
delete all .idea directories.
open PyCharm and add project from correct directory.
That's it.
I had the same issue. My solution was:
Close project.
Rename the folder you want to dissapear
Open pycharm project. A dialog will be shown asking if you want Pycharm remove the folder. Answer: yes.
That is enough.
In version 2017.2.1
File → Close Project
You will be taken to the start-up window, where you can see the projects you've created on the left. You can then delete a project by clicking the cross sign ('x') following the project name.
Related
I made a variable cfg = waterot.cfg and then made a new file "waterot.cfg" in pycharm, this automatically made a pyvenv.cfgfile, I didn't know what this was and I was getting errors with my code I deleted the pyvenv.cfg file and changed from .cfg to .txt. Now when I run my code I get an error No pyvvenv.cfg file
This is the problematic piece of code
redeemkey = message.author
if redeemkey.startswith('!download'):
if message.channel.id == 695834994064490658:
with open ('waterOT.txt', 'rb') as otcfg:
await message.author.send(file=discord.File(otcfg, 'waterOT.cfg'))
await message.delete()
In my case I tried many ways, but finally I do one thing that solve my error.
I just delete existing venv directory and set Project Interpreter from my editor.
If you know the path for the python distribution used to create the virtual environment, and it's version, you can just create yourself a pyvenv.cfg file with following contents
home = <location-of-python-exe>
include-system-site-packages = false
version = <version>
where
<location-of-python-exe> is the folder where the python.exe is located that was used to create the python virtual environment. Example C:\Python\Python385-64.
<version> is the version of the python, at <location-of-python-exe>. You can check it by running <location-of-python-exe>\python.exe. Example: 3.8.5.
Valid locations for the pyvenv.cfg are (PEP405):
Next to the python executable (venv/Scripts/pyvenv.cfg), i.e. in the same folder with python.exe.
One directory up from the python executable; root of the virtual environment (venv/pyvenv.cfg)
where venv is the assumed name of the virtual environment (could be something else, too).
With PyCharm you can restore that change in a couple of clicks:
Right-click anywhere in the editor and choose Local History | Show History from the context menu.
In the dialog that opens, the left-hand pane shows a list of all saved revisions of the current file with timestamps. The right-hand pane shows a diff viewer which displays the differences between each revision and the current state of the file.
OR
Do one of the following:
To revert the whole file or directory to the state of this revision, right-click it and choose Revert from the context menu or click the Revert icon on the toolbar.
To restore a specific code fragment, select the revision that contains that fragment. In the diff view on the right locate the piece of code you want to restore click the chevron button the Chevron button to copy it from the left pane.
The easiest way is to chose 'file' in left hand corner of pycharm window, then choose restart IDE, then follow the steps of restarting settings of IDE. It worked for me.
pyvenv.cfg is a configuration file for a virtual environment. Without knowing how you set things up, I assume Pycharm made the virtual environment.
You should not delete the pyvenv.cfg file if you want the virtual environment to work.
Pycharm doesn't recognize the packages of my project's modules.
I noticed there are already quite some questions on this, but I tried all the given solutions and nothing works.
I tried:
- Mark directory as source root & checking Add sources root to pythonpath
- Opening a different project and then reopening the original one to make pycharm reindex the packages
Any suggestions?
I went over the following questions
PyCharm does not recognize modules installed in development mode
Pycharm not recognizing packages even when __init__.py exits
Just in case people got here with a similar trouble as I am. I had all files __init__.py correctly but pycharm didn't recognize those package properly. Finally, this following way worked for me:
In pycharm,
1. right click on a base folder of your code
2. Choose "make Directory as"
3. Choose "Sources Root"
Hope this helps.
Ok it is quite funny to answer my own question, but I understood that is the encouraged way to go if you actually found the answer.
So what was causing this problem was that __init__.py was listed as a text file in Pycharm settings.
If you go to Settings | File Types | Select Text you see a list of file names/extensions that Pycharm recognizes as text.
I think this happened because I created a file named __init__ without file extension, and later changed it to __init__.py
Removing it from there fixed the issue.
I would suggest the following
Close pycharm
Delete the .idea folder
Open the project as new project
Make sure you have the __init__.py files where they belong (each package needs one)
It should not be necessary in this case to add anything to the pythonpath or source root manually. This is only necessary if you work on two projects with are disconnected from each other and you want them to be able to import from each other.
In the latest release of Pycharm, setting the project folder as "content root" fixes your problem.
Go to Preferences
Go to Project -> Project Structure
Add content root with your project directory path
When I run my Main.py script, PyCharm keeps telling me Cannot start process, the working directory /home/myname/PyCharmProjects/MyProjectName/mypackage does not exist.
This error occurred after creating a package (mypackage) for test purposes, moving files to it (including Main.py), and moving the files back to the root folder afterwards.
The package mypackage was empty after that, but PyCharm still thought that Main.py is located in that package. I could still run the program until I deleted the empty package, but path errors occurred. After deleting the package, I was unable to start it.
I can still run the other files that used to be in mypackage and are now in my root directory again.
I can still create and run new files in my root directory.
It happens because when you create a file it automatically assigns the working directory to it's configuration, which of course is the one where you created it.
You can change that by going into Run -> Edit Configurations. Click on the folder icon in Script path: and correct the path to the file. Click OK to save and you should be able to Run the file again.
After testing for a bit, I've found a solution (but not an answer to why this error occurs in PyCharm):
Delete the file and create it again. (Or rename or move it and create a new file with its old name, both should work.)
Set the working directory correctly
1. File-> Settings
2. Build, Execution, Deployment -> Console -> Python Console
3. Working directory: [The path to the directory where the file you're currently working on resides.]
I had the same problem, mine is probably related to the explaination gave by the others, it comes from the dir .idea, files *.xml contain the variable $DIR_PROJECT$.
Therefore, as the attribution of a new path didn't work, I just deleted my .idea, that is automatically loaded each time I open my project's directory.
It automatically regenerated the .idea, asked for the script path... And it worked perfectly
CAREFUL => You will automatically lose your project settings, you are deleting the "settings file"
I was getting this same error, and the path in "edit configurations" was correct.
However, this is what eventually got my code working again.
1) I commented out all of the code in my file ("ctrl" + "a" + "ctrl" + "/")
2) I commented something I knew would compile in the file. (my list of imports)
3) I ran the python file.
This time, it actually completely compiled and after that I was able to uncomment the rest of my code and everything worked again.
The issue kept popping up over and over in PyCharm. So I created a new project and loaded the needed script. Then I provided the directory to path and assigned the default Python version that I wanted to use... and it worked. Then I was able to finally use "execute line in console" once again.
I had this problem because I renamed my project, it was "xx" I renamed it to "yy", what I did was I went through the directory of .idea in the "yy", in any of those files (all XML files) if there were the name "xx", I replaced it with "yy"
I experienced this problem after moving my project to a different root directory. None of the above solutions worked for me.
I solved it by opening my entire project folder, instead of just the python file I was trying to run. And then running the file I wanted, while the entire project was loaded into PyCharm.
open the qtdesigner work dictionary setting and choose your project path then click OK, don't not use the mysterious work dictionary path by default
In my case Run -> Edit Configuration didn't help.
I've solved it changing the value of "WORKING_DIRECTORY" attribute in .idea -> workspace.xml
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/your/correct/path/here" />
I am a beginner so appreciated this 6 year and 6 month discussion. I couldn't add a comment. I setup PyCharm 2022.1.1 and a Python 3.10.4 virtual environment with pyside2 and pyside6 on Ubuntu 22.04. I tried all the suggestions above and could get none of them to work for me. Following these instructions: https://pythonpyqt.com/how-to-install-pyqt5-in-pycharm/ both pyside2-designer (Qt5Designer) and pyside6-designer from my virtual environment were added as external tools. pyside2-designer failed with the working directory error and pyside6-designer worked without any error. Looking closer at pyside2-designer selecting the working directory with the browse button, I still could not create file - exit code was 127 - but the Qt5 Designer was available for existing ui files. I used pyside2 because PyQt5-tools could not be pip installed in my python3.10.4 virtual env.
This worked for me on PyCharm 2021.3.2:
Such as:
It can not show tipMember.objects when I type Member.o.(Member is a django model)
And same with python build-in function, like for,filter, map and so on.
This feature worked yesterday, I don't know why it broken now.
I have tried Invalidate Caches / Restart, do not work.
UPDATE
Maybe I know what is the problem.
I have a big folder name ALL project, it is my project. and project A under ALL project.
I accidentally mark project A excluded. And I use File -> Open .. to add it back.
It seems pycharm create .idea folder under project A, it means pycharm treat project A as a project.I have to set Project Interpreter for project A in order to get auto-completion back.
I don't want pycharm treat project A as a project. I want it treat project A as a folder, then it would use the Project Interpreter of ALL project.
Ok, I find that Project Structure dialog in File | Settings | Project Structure . Adding the folder back make every thing fine.
Have you set project interpreter correctly, i also had this problem when i started using pycharm, it can be also because of your editor settings file>editor>code-completion.
Relatively new to Python and PyCharm and as such most of the work. I'm doing is single files and therefore is not organized into projects.
Is there a way to configure Pycharm to be used to open single files and not use projects?
Similarly, is it possible to just run a single page/file?
On Pycharm 5.0.4...
Open the file (i.e. by double clicking in explorer)
Navigate to File->Settings...
Expand the Project tab on the left and select 'project interpreter' from the options that appear beneath
Set your project interpreter from the dropdown menu, and you should be able now to run your file without creating a project
You can always open a single file (File > Open) but to actually run or debug the code from within Pycharm, or use most of its other features, it needs a correctly configured project.
What you can do is create a single project to hold all of your "assorted" code. I usually recommend creating a virtualenv for this project as well and using that as your Pycharm project interpreter. You can further divide this project into different packages to keep things organized.
Update: PyCharm 4.5 now provide Scratch Files which seem relevant to this question.
You have to work with a configured project (indicated by folders) but there is a work around... In Pycharm when you create a project you will have a default file in .py or any other format.
Just follow the steps to work with individual files..
right click on the folder (in left hand side project tree) and add new python file
double click on the newly added file ,it will now be open in a new tab
(BUT..if you try to run this new file pycharm will still compile the previous file ...so to change that..)
right click on the tab of your file and click run "file name" or you can press CTRL+shift+F10
done :)
From the command line
pycharm [path_to_your_file]
where pycharm on my machine is aliased to /opt/pycharm-community-3.1.1/bin/pycharm.sh in file ~/.bash_aliases.
As Preston mentioned, not all features seem to work: for example, navigation between files does not seem to work.
You can also create a .py file and implement it within a PyCharm project by dragging it into the editor. This method also allows you to use a separate text editor to create your .py file.