如何确认Heroku所用Postgres已正确安装并解决相关报错?
Hi there, let's break down your issues step by step—they're actually separate problems, and neither is directly caused by a faulty Postgres installation (at least not the first one):
1. Why pipenv --three throws the "command not found" error
This error has nothing to do with Postgres—it means your Windows system can't find the pipenv executable in its PATH environment variable. Here's how to fix it:
- First, make sure you've actually installed pipenv. Open a CMD/PowerShell window and run:
If you have multiple Python versions installed, usepip install pipenvpip3instead ofpipto ensure it's installed for your Python 3 environment. - Next, add pipenv's installation path to your Windows PATH:
- The default path is usually
C:\Users\<YourUsername>\AppData\Roaming\Python\PythonXX\Scripts(replace<YourUsername>with your Windows username, andXXwith your Python version, e.g.,3.7). - Alternatively, if you installed Python globally, it might be
C:\Program Files\PythonXX\Scripts. - After adding the path, close and reopen your terminal window, then try
pipenv --threeagain.
- The default path is usually
2. Troubleshooting heroku pg:psql issues
The heroku pg:psql command connects your local terminal to your Heroku app's cloud-hosted Postgres database. The empty output you're seeing likely comes from one of these issues:
- Local
psqlclient isn't in your PATH: Heroku CLI relies on your local Postgrespsqlexecutable to establish the connection.- Fix this by adding your Postgres
bindirectory to Windows PATH. The default path isC:\Program Files\PostgreSQL\10\bin(since you installed Postgres 10.1). - Restart your terminal after updating the PATH, then try
heroku pg:psqlagain.
- Fix this by adding your Postgres
- You're not logged into Heroku or in the wrong directory:
- Run
heroku loginto authenticate your CLI session. - Make sure your terminal's working directory is the local folder of your Heroku app (where your
Procfile/requirements.txtlives).
- Run
- Your Heroku app doesn't have a Postgres add-on:
- Check if Postgres is enabled with
heroku addons. If you don't seeheroku-postgresqllisted, add it with:heroku addons:create heroku-postgresql:hobby-dev
- Check if Postgres is enabled with
3. How to confirm your local Postgres is installed correctly
To verify your local Postgres setup independently of Heroku:
- Open the
pgAdmin 4tool that came with your Postgres installation—try connecting to the default local database (port 5432, usernamepostgres). If it connects successfully, your local Postgres is working. - Or, open a CMD window and run:
If you're able to enter the Postgres command-line prompt, your local installation is functioning properly.psql -U postgres
内容的提问来源于stack exchange,提问作者H42
相关产品推荐
相关产品推荐

