Location directory is not empty while creating project in pyCharm

Answered

I'm trying to create a new python project but when I'm selecting a location it gives as message that location directory is not empty even if the directory is empty.

1
26 comments

I was just having the same issue with the 2018.1 Community Edition. I was able to resolve the issue by deleting the project from my "virtualenvs" directory. After that I was able to recreate the project.

3

Hello Friend!
Open the following shortcut (Ctrl + Alt + S), and click (Project: xxxx), now choose (Project Structure) and select (home / yourUser / PycharmProjects / XXXX / venv / bin) and right-click (Excluded) or (Alt + E).
Now click (+ Add Content Root) and see if it points to the following location (/ home / yourUser / PycharmProjects / XXXXX / venv / bin) and click OK.
Now close the IDE and open it again.

2

I solved this issue.

What you need to do is delete everything in the ven folder (/ home / yourUser / PycharmProjects / XXXXX / venv / bin), which is located in your project.

The reason is that your ven folder is the place where the environment location located in. If ven folder is not empty like you have already had python3.5 Project Interpreter, you want to change the Interpreter to python2.7, but python2.7 needs another empty folder to place it,  then this error will occur.

 

2

For people like me that didn't carefully "read" the UI (I am using IntelliJ UE 2022.3.2 btw): 

The Add Python Interpreter interface is a radio button group with two parts.

  1. The top part says New environment
  2. The bottom is for Existing environment

Be sure to use the bottom one if you already created your venv and just want to hook things up.

2

I am using 2018.2 version. but i got the same issue.how can I choose the environment I just created. hope the issue can be solved quickly!

1

I am using 2018.1 (just installed a few days ago). I am getting the same error.

Here's what I know about my situation.

I started to create a virtual environment, but after initial creation, couldn't find my venv directory, so closed the project and then

deleted the entire directory.

I now try one more time to create a virtual environment with the same name as before, and even though I deleted the entire directory before starting, get the 'Environment location directory is not empty' error.

 

0

I am using 2018.1 version. And I got the same bug. I can`t change my project environment to a conda environment. 

0

Asrivastava's comment worked for me.  I went into the file directory on my computer and deleted the "venv" file for the project and it worked.

0

maybe I made virtualenv environment bad, so I  use  System Interpreter

0

it seems that nobody can solve the problem!!!  feel bad!!!

0

I solved this issue.

 

Settings > Project Interpreter>

1. Create virtual environment so that we can modify its path later.

            To add: Add > Select any empty directory in location field -> Select any previous executable in Base interpreter and apply setting.

 

After you created virtual environment.

Show all >

Select last interpreter you created >

Locate your desirable virtualenv executable path and save the setting. 

Restart the Pycharm and enjoy.

 

Thanks, olidebnedra@gmail.com for any other problem.

 

0

Just go to your Anaconda3 (in case you are using Anaconda3) folder and from there go to envs and then delete the folder of your project. Now you'll be able to create a new project with the same name. 

And you also need to delete it from PyCharm Project folder and that I think should be very obvious to you all.  

0

I have added in the front of venv in this case venv27 in add Python Interpreter > New environment > Location "C:\dev\kivy\venv" and worked for me. Thanks.

0

Thanks Ziyiliu29! I solved this problem through Ziyiliu29's way.

0

Oct 28, 2021. This problem is still not fixed. Unacceptable.

0

Hello Douglas Hoen

This has been fixed.  Could you please attach a couple of screenshots: the projects configuration with the warning and location in the file browser? Thank you in advance! 

0

I am experiencing this issue in Pycharm 2021.3. Why doesn't this string have a conclusive resolution ? 

0

Hello Bernard Mallala

 

Could you please share a couple of screenshots? Regrettably, this is not reproducible for me. You are very welcome to report the bug directly

 https://youtrack.jetbrains.com/issues/PY, please attach steps to reproduce, 

logs folder zipped from ***Help | Collect logs and Diagnostic Data***    and screenshots/screencast presenting the behaviour. 

 

 

0

So, I had the same problem with Ubuntu 22.04 and PyCharm's newest professional edition (2022.1.2). I tried everything mentioned above, but nothing worked.

So what I did and managed to 'fix' it: sudo apt-get install python3-venv

Yeah, that did the trick, no more 'directory is not empty'.

Simply create a project as usual and it works..

Hope I could help you all!

Have a nice day

0

I faced a similar message on working with PyCharm 2022.1.2 Professional Edition on Mac OS.

The situation in my case was after I created a new project in PyCharm with a conda virtual environment (miniforge3) and then deciding to delete it all together and recreate a fresh project under the same name.

Here are the steps I took first to delete the project and environment:

1. Go to Preferences > Project: project_name > Python Interpreter > click the drop down list and "Show All..." > select the project's interpreter and click the (-) sign.

2. Delete the project folder in `$HOME/PycharmProjects`, for example in the command line: `rm -r $HOME/PycharmProjects/cool_project`

However, after these steps I still got the message "Location directory is not empty" when trying to create a new project under the same name.

To solve this I had to remove the folder in the virtual environment manager directory, as follows (this path will vary depending on the system and manager used):

3. In the command line: `rm -r $HOME/miniforge3/envs/cool_project`

Only after the last step (3) was the problem solved and I was able to recreate the project in PyCharm using the same name (e.g., cool_project).

I hope this helps.

0

I am getting this error when trying to import a project that was just cloned from git. There is no venv directory to remove. I tried installing python3-venv (using Fedora), but it wasn't found. How can I fix this very frustrating problem?

0

I tried all of the above. Unfortunately I couldn't find a solution... JETBRAINS PLEASE HELP ME MY DEADLINE IS TOMORROW I DON'T KNOW WHAT I SHOULD DO HEEEELPP

0

Hi nnn,

Please try to create a virtual environment with the "python -m venv %venvname%" command in the same folder; if it fails, then something is wrong with the directory (probably a hidden folder); otherwise you'll get the required environment, which you can add to PyCharm after and please create a separate bug report on Youtrack , attach a log file (Help | Show logs in...) and screenshots of the directory (with hidden folders shown) and your Create virtual environment window.

0

This is worked for me. I was trying to create New environment.

0

What worked for me: I made a folder

When I clicked on “Previously configured interpreter” it allowed me to select Python 3.11.

I got the error “Location directory is not empty”

The location showed C:\users\username  so I created the folder PycharmProjects in the directory “username” . 

I then changed the location to C:\users\username\PycharmProjects

The error message went away. A folder for my PycharmProjects was not created during the installation. The basic document directory "username" was in fact not empty. All the program wanted was an empty directory so I made it one.

 

0

Please sign in to leave a comment.