Change the default location of Pycharm Project

2020-02-23 05:31发布

问题:

I am using PyCharm 3.4.1 on Ubuntu 14.04. For new project it suggests ~/PyCharmProjects for storing project folders. Is it possible to change the location and name of this proposed folder?

(I couldn't find any reference to changing it in the interface, on the JetBrains site, or in the settings files. Either it isn't possible or (I hope) I missed something.)

Note, it is not a duplicate of Can I change the location/name of PyCharmProjects? - I am aware that it is possible to change proposed path for every created project - but I want defaults that I like.

回答1:

In fact, this is possible. In the IDE settings folder (https://www.jetbrains.com/help/pycharm/project-and-ide-settings.html), under config/options/recentProjectDirectories.xml, you can add an option lastProjectLocation. It wil honor this setting when creating new projects. My recentProjectDirectories.xml looks like this:

<application>
  <component name="RecentDirectoryProjectsManager">
    <option name="lastProjectLocation" value="$USER_HOME$/my_projects" />
  </component>
</application>

In fact, for most options that you want to customize, you could do a diff of the config/options folder before and after you make the change: this way you can find out a lot about how PyCharm (or any IntelliJ tool) configures its editor.



回答2:

I haven't found an explicit option for doing this in PyCharm, but the following steps have worked as an alternative:

  • Move your PycharmProjects folder to the desired location.
  • When you create a new project, press the "..." button to the right of the path (This is on the pop up window that asks for location and interpreter).
  • Navigate to the new location of PycharmProjects and select that directory.
  • Add the name of the new project to the directory location (ie. /home/alex/Documents/PycharmProjects/new_project_name)

Now, whenever you create a new project, the location will default to the last chosen path.

This wouldn't be a good solution for someone who is creating projects in many different directories, rather than just PycharmProjects. All my projects are within PycharmProjects and this works just fine.



回答3:

It's not a provided option. See this old thread (2003) on devnet.jetbrains.com where this is being discussed.

Subsequent requests to specify a default directory for projects has gone unanswered:

  • https://devnet.jetbrains.com/thread/157005;jsessionid=5A2C7A1F90969DEAD3908924FFF1AF3A?tstart=1
  • https://devnet.jetbrains.com/message/857698
  • https://devnet.jetbrains.com/thread/67231;jsessionid=5255DB0AAB942F0DCDF1B86AFFE54976


回答4:

PyCharm (since at least version 2017) remembers the parent directory of the last place where you created a project. So create a junk project in the directory that you want to be your default projects directory, then close that project, and delete it from disk. The next time you create a project, pycharm will automatically put you in that directory.



回答5:

Just like virtualenvwrapper, PyCharm apparently obeys $PROJECT_HOME

export PROJECT_HOME=$HOME/Devel
pycharm

or

PROJECT_HOME=$HOME/Devel pycharm


回答6:

I would have to agree, because I could not find an option in the program. However, based on the answers, found a folder labeled (in my case) \Users\.PyCharmCE2018.1\config\options

In this folder there are XMLs, one named option with a tag "file.chooser.recent.files". I worked with this, which I found to work for me.