xbeewificloudkit icon indicating copy to clipboard operation
xbeewificloudkit copied to clipboard

heroku run python manage.py syncdb

Open arunnediyasala opened this issue 7 years ago • 74 comments

$ heroku run python manage.py syncdb After executing the above command I am getting the following error.Please have a look Traceback (most recent call last): File "/app/xbeewifiapp/settings.py", line 344, in SECRET_CRYPTO_KEY = binascii.a2b_hex(os.environ['AES_CRYPTO_KEY_HEX']) File "/app/.heroku/python/lib/python3.6/os.py", line 669, in getitem raise KeyError(key) from None KeyError: 'AES_CRYPTO_KEY_HEX'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "manage.py", line 18, in execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/init.py", line 453, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/init.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/init.py", line 263, in fetch_command app_name = get_commands()[subcommand] File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/init.py", line 109, in get_commands apps = settings.INSTALLED_APPS File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/init.py", line 53, in getattr self._setup(name) File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/init.py", line 48, in _setup self._wrapped = Settings(settings_module) File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/init.py", line 132, in init mod = importlib.import_module(self.SETTINGS_MODULE) File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/importlib.py", line 35, in import_module import(name) File "/app/xbeewifiapp/settings.py", line 348, in os.environ['AES_CRYPTO_KEY_HEX'] = SECRET_CRYPTO_KEY File "/app/.heroku/python/lib/python3.6/os.py", line 674, in setitem value = self.encodevalue(value) File "/app/.heroku/python/lib/python3.6/os.py", line 744, in encode raise TypeError("str expected, not %s" % type(value).name) TypeError: str expected, not bytes

arunnediyasala avatar Jan 02 '18 16:01 arunnediyasala

As of a few months ago, Heroku switched the default Python runtime for newly created apps from Python 2.7 (which is what this application is compatible with) to Python 3.6. As such, you will need to force Heroku to use Python 2.7 with your instance. See documentation here.

You can accomplish this with the following commands (should work under Linux as well as Windows, in case you are using Windows):

$ echo python-2.7.14 > runtime.txt
$ git add runtime.txt
$ git commit -m "Add runtime.txt file to force Heroku to use Python 2.7"
$ git push heroku master

This application is not actively maintained any more, so we missed this change.

mikewadsten avatar Jan 02 '18 16:01 mikewadsten

Hi, Because of Python 3.6 in Heroku I have removed wsgiref==0.1.2 and also updated static versions etc.I hope this change wont affect my deployment

arunnediyasala avatar Jan 02 '18 17:01 arunnediyasala

Because of Python 3.6 in Heroku I have removed wsgiref==0.1.2

I would recommend you change the requirements.txt file back to the master branch version, and simply try adding the runtime.txt file first. We have not tested the application with newer versions of the Python library dependencies, and cannot be sure that everything will work if you do that.

mikewadsten avatar Jan 02 '18 17:01 mikewadsten

Hi, I am getting a sample page like this https://enigmatic-gorge-49618.herokuapp.com/ I did not see any widget in my page....So xbeeWificloudkit is just a sample to create a webpage???

arunnediyasala avatar Jan 02 '18 17:01 arunnediyasala

Something seems to have gone wrong with the application deployment. You should get a webpage that looks like https://xbeewifi.herokuapp.com

Run the following commands, then see if the app is working correctly:

$ git checkout origin/master -- requirements.txt package.json bower.json
$ git commit requirements.txt package.json bower.json -m "Revert library dependencies to upstream"
$ git push heroku master

(If the second command comes back with a message that ends with "no changes added to commit", then apparently that's not the issue.)

mikewadsten avatar Jan 02 '18 17:01 mikewadsten

When I used the command git checkout origin/master -- requirements.txt package.json bower.json fatal: invalid reference: origin/master then I used git show-branch -a

  • [master] master runtimefile ! [heroku/master] master runtimefile -- *+ [master] master runtimefile

Then I used git checkout heroku/master -- requirements.txt package.json bower.json After that executed second command I am getting evert library dependencies to upstream" On branch master nothing to commit, working directory clean

arunnediyasala avatar Jan 02 '18 17:01 arunnediyasala

Can you run the following command and tell me the output?

git remote -a

The intent of that git checkout command is to revert the state of those 3 files to match the state of the current master branch of this GitHub repository. I assume you cloned this repository (using something like git clone https://github.com/digidotcom/xbeewificloudkit, in which case this repo should be one of the remotes in your local copy).

Alternately, you could try this command: git checkout cc37a84c40 -- requirements.txt package.json bower.json

If instead of cloning this repository, you downloaded the files and started from there, you can run these commands:

$ git remote add origin https://github.com/digidotcom/xbeewificloudkit
$ git fetch origin

then run the git checkout command.

mikewadsten avatar Jan 02 '18 18:01 mikewadsten

out put of git remote -a heroku https://git.heroku.com/enigmatic-gorge-49618.git (fetch) heroku https://git.heroku.com/enigmatic-gorge-49618.git (push)

arunnediyasala avatar Jan 02 '18 18:01 arunnediyasala

out put of git remote -a

Thanks. Can you run the last set of commands I added to my previous command (git remote add and git fetch), then try the checkout command with origin/master again? It should work then.

mikewadsten avatar Jan 02 '18 18:01 mikewadsten

Sorry for the delay there is some internet issue from my side mean while git remote add " what I have to give here "

arunnediyasala avatar Jan 02 '18 19:01 arunnediyasala

git remote add " what I have to give here "

Run these commands:

$ git remote add origin https://github.com/digidotcom/xbeewificloudkit
$ git fetch origin

then you should be able to run these commands:

$ git checkout origin/master -- requirements.txt package.json bower.json
$ git commit -m "Revert library dependencies to upstream" -- requirements.txt package.json bower.json
$ git push heroku master

mikewadsten avatar Jan 02 '18 19:01 mikewadsten

Still I am getting the same https://enigmatic-gorge-49618.herokuapp.com/

arunnediyasala avatar Jan 02 '18 20:01 arunnediyasala

git remote -v heroku https://git.heroku.com/enigmatic-gorge-49618.git (fetch) heroku https://git.heroku.com/enigmatic-gorge-49618.git (push) origin https://github.com/digidotcom/xbeewificloudkit (fetch) origin https://github.com/digidotcom/xbeewificloudkit (push)

arunnediyasala avatar Jan 02 '18 20:01 arunnediyasala

It seems like you may need to purge the build cache (see https://help.heroku.com/18PI5RSY/how-do-i-clear-the-build-cache)... so run the following commands, then attach the deploy_log.txt file to a reply here:

$ heroku plugins:install heroku-repo
$ heroku repo:purge_cache -a enigmatic-gorge-49618
$ heroku repo:reset -a enigmatic-gorge-49618
$ git push heroku master > deploy_log.txt 2>&1

mikewadsten avatar Jan 02 '18 20:01 mikewadsten

deploy_log.txt Thanks for your replay here I am attaching the log file.

arunnediyasala avatar Jan 02 '18 21:01 arunnediyasala

Based on that log file, it does appear that the static asset build (done by JavaScript during the deploy) is succeeding. However, there is this message:

remote: -----> Python app detected        
remote:  !     The latest version of Python 2 is python-2.7.14 (you are using python-2.7.12, which is unsupported).        
remote:  !     We recommend upgrading by specifying the latest version (python-2.7.14).        
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes        

Can you look in the runtime.txt file and make sure it says python-2.7.14? Based on that error message it might say python-2.7.12. If you do need to change it, run these commands:

$ echo python-2.7.14 > runtime.txt
$ git commit -m "Change Python to 2.7.14" -- runtime.txt
$ git push heroku master

mikewadsten avatar Jan 02 '18 22:01 mikewadsten

Actually, hold on. Have you run heroku run python manage.py syncdb now that you got the successful deploy using Python 2.7?

mikewadsten avatar Jan 02 '18 22:01 mikewadsten

Yes I run that

arunnediyasala avatar Jan 02 '18 22:01 arunnediyasala

heroku run python manage.py syncdb Running python manage.py syncdb on ⬢ enigmatic-gorge-49618... up, run.2723 (Free) Creating tables ... Installing custom SQL ... Installing indexes ... Installed 0 object(s) from 0 fixture(s)

I have python version 2.7.12 so I run like this echo python-2.7.12 > runtime.txt I hope I need python-2.7.14

arunnediyasala avatar Jan 02 '18 22:01 arunnediyasala

Python app detected remote: -----> Found python-2.7.12, removing remote: -----> Installing python-2.7.14 remote: -----> Installing pip remote: -----> Installing requirements with pip Then also I am getting the same page ..

arunnediyasala avatar Jan 02 '18 22:01 arunnediyasala

The version of Python that you have installed locally has no effect on what you should put in runtime.txt. That file controls the version of Python that Heroku uses. Based on that error message in the log, it appears that Heroku officially supports 2.7.14, so that's what you should specify.

It looks like the issue might actually be in caching the static assets:

remote: -----> Caching build        
remote:        Clearing previous node cache        
remote:        Saving 2 cacheDirectories (default):        
remote:        - node_modules        
remote:        - bower_components (nothing to cache)  

The static assets get built into a directory named static, and it appears that Heroku is not caching that directory (based on my interpretation of this information). Try editing package.json as follows:

  "peerDependencies": {
    "karma": "~0.10"
- }
+ },
+ "cacheDirectories": ["node_modules", "static"]
}

(add the "cacheDirectories" entry). Then:

$ git commit -m "Specify cacheDirectories" -- package.json
$ git push heroku master

This should help ensure that the front-end static files get cached in Heroku.

mikewadsten avatar Jan 02 '18 22:01 mikewadsten

Caching build remote: Clearing previous node cache remote: Saving 2 cacheDirectories (package.json): remote: - node_modules remote: - static (nothing to cache) remote: remote: -----> Build succeeded! remote: ! This version of npm (2.13.5) does not support package-lock.json. Please

Getting same web page like previous result

arunnediyasala avatar Jan 02 '18 22:01 arunnediyasala

remote: -----> Caching build remote: Clearing previous node cache remote: Saving 2 cacheDirectories (package.json): remote: - node_modules remote: - static (nothing to cache) remote: remote: -----> Build succeeded! remote: ! This version of npm (2.13.5) does not support package-lock.json. Please update your npm version in package.json. remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-an-npm-version remote: remote: -----> Python app detected remote: -----> Installing requirements with pip remote: remote: -----> Discovering process types remote: Procfile declares types -> web remote: remote: -----> Compressing... remote: Done: 92.8M remote: -----> Launching... remote: Released v14 remote: https://enigmatic-gorge-49618.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy... done. To https://git.heroku.com/enigmatic-gorge-49618.git fe8e666..a6dff50 master -> master Now I not that my npm version . Is this is the real problem

arunnediyasala avatar Jan 02 '18 22:01 arunnediyasala

Now I not that my npm version . Is this is the real problem

If you mean "this is not the same version of NPM that I have installed on my PC", then no. Heroku builds and runs the application inside what is more or less a virtual machine in the cloud. What versions of Python and Node and NPM you have installed on your personal machine does not matter.

Getting same web page like previous result

Sorry, I was wrong about which directory contains the static assets. Turns out it's inside prod/static. So on the cacheDirectories line of package.json, change "static" to "prod". Then:

$ git commit -m "Cache the correct directory for front-end assets" -- package.json
$ git push heroku master

mikewadsten avatar Jan 02 '18 22:01 mikewadsten

When I updated package.json and then I try to push it in to heroku sudo git push heroku master Everything up-to-date same webpage I am getting

arunnediyasala avatar Jan 02 '18 23:01 arunnediyasala

After editing package.json, did you commit the change? (First command in my previous comment)

mikewadsten avatar Jan 02 '18 23:01 mikewadsten

yes.I am following the same

arunnediyasala avatar Jan 02 '18 23:01 arunnediyasala

Based on this:

sudo git push heroku master Everything up-to-date

It does not appear that the deployment to Heroku did anything. What if you run the git push heroku master command without sudo? (You shouldn't need to use sudo for these Git operations)

mikewadsten avatar Jan 02 '18 23:01 mikewadsten

git push heroku master error: update_ref failed for ref 'refs/remotes/heroku/master': cannot lock ref 'refs/remotes/heroku/master': Unable to create '/home/arun/Downloads/xbeewificloudkit-master/.git/refs/remotes/heroku/master.lock': Permission denied Everything up-to-date But when I run sudo git push heroku master Everything up-to-date

arunnediyasala avatar Jan 02 '18 23:01 arunnediyasala

Okay, that error is probably because you had used sudo previously.

Can you send me the output of this command?

git log --decorate -n 3

mikewadsten avatar Jan 02 '18 23:01 mikewadsten