I have a Python project that has a requirements.txt
project for pip install
to use. I have opened that project in PyCharm. (Side note: PyCharm uses many of the same engines as IntelliJ when it comes to Git integration, so I've tagged that, too).
Upon opening a Python file, as expected PyCharm tells me, "Package requirements are not satisfied." I click "Install Requirements" and after a short time get some errors. All of the errors are related to private GitHub repositories (in requirements.txt
as "git+ssh://[email protected]..."). All of the errors are the same:
Please make sure you have the correct access rights
and the repository exists.
I can run pip install
from the command line without issue, so the problem is not with requirements.txt. The problem appears to be PyCharm not using my GitHub SSH keys (it has never asked me for my SSH key password). The PyCharm docs say to make sure that your public and private keys exist in $HOME/.ssh/id_rsa.pub
and $HOME/.ssh/id_rsa
, respectively, and they do. I have also set up GitHub settings so that PyCharm knows my username and password, but that also did not work.
None of the public Git/GitHub repositories in requirements.txt
cause any problems (they all installed fine). It's only these two private GitHub repositories that PyCharm can't seem to install requirements from.
How do I get PyCharm to use my GitHub SSH keys when installing requirements from requirements.txt
?
Press Ctrl+Alt+S to open the IDE settings and select Tools | Python Integrated Tools. In the Package requirements file field, type the name of the requirements file or click the browse button and locate the desired file. Click OK to save the changes.
Open the project that you want to put under Git. From the main menu, choose VCS | Create Git Repository. In the dialog that opens, specify the directory where a new Git repository will be created.
This completes the steps for integration of GitHub Repo with PyCharm. To clone the GitHub Repository created in the first step, open PyCharm → Go to Menu VCS → Get from Version Control → Select GitHub → Select the Repo to clone, and Confirm.. and That's it !
Do one of the following: To push changes from the current branch press Ctrl+Shift+K or choose Git | Push from the main menu. To push changes from any local branch that has a remote, select this branch in the Branches popup and choose Push from the list of actions.
One workaround is to open PyCharm (or Intelli-J) from the console, instead of via the Application icon, or the project.
Make sure you have created a command line launcher from the tools menu, then use the newly available charm
command to open your project. It's possible to also just run open /Applications/PyCharm.app
, but I believe charm
also allows you to specify the project to open.
Instances of PyCharm launched in this way will have inherited your terminal environment. I will admit I haven't tested private Git repositories in requirements.txt with this, but it has solved other issues related to the environment, so I'd give it a try.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With