Error: trying to push Table SQLAlchemy models to my production heroku-server using Alembic - postgresql

I am trying to push my SQLAlchemy-models to create Tables in my heroku-postgres-database. I use this command:
heroku run alembic upgrade head
It starts to Run as expected. But after a while I just get error,
Bash: alembic: command not found.
How to resolve it?

I had the same problem and solved it, not sure it will work for everyone. I noticed that in my requirements.txt file, I did not have the alembic package listed. So alembic was not installed loading the files on Heroku! I tried using heroku run pip install alembic, which installed the package successfully but still didn't solve the problem! I tried heroku run alembic --version, still the same.
The way I solved it is by deleting the local requirments.txt folder and generated it again using pip freeze > requirements.txt, this time alembic was there of course! After pushing my changes to heroku everything worked fine!

I think you are using quotes in the command. If so, remove the quotation marks

Related

Postgres/VirtualEnv/Flask

This one may be for the experts!
So here is the problem:
I have a flask app that gets its data from Postgresql and it runs fine in my normal environment. I tried to deploy it locally using virtualenv and after pip installing all the requirements the only one that gave me trouble is psycopg2 which appears to be dependency of Postgresql.
I then used this amazing article to help me install it, by putting export PATH=/Library/PostgreSQL/9.3/bin:$PATH to the .bash_profile file.
But now I get this error:
Library not loaded: libssl.1.0.0.dylib ...Image not found
What is going on?

Ember-cli 0.2.5 livereload keeps reloading in every change

After updating to ember-cli 0.2.5 (same think with 0.2.4; 0.2.3 was ok), when i make a change to a file and save it, it keeps reloading my app at least 3 times for each save i do. Server's console shows file added... file added... file added... for all my app files each time, but my tmp folder is always empty. Also is seems that for each reload it tries to create a folder inside tmp folder, but it quickly removes it every time. The only file inside tmp folder is .metadata_never_index. Does this have to do with caching? Any help? I'm on yosemite.
I had this problem with watchman 3.1.0 (which is the version that Homebrew installs) so I upgraded to 3.1.1 and it seems to have been resolved.
You'll need to install it from source, but it's easy:
$ brew uninstall watchman
Then just
$ git clone https://github.com/facebook/watchman.git
$ cd watchman
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install
Fingers crossed it seems to have worked so far (thank goodness, as it was driving me CRAZY).
For anyone else that has the same problem, i reinstall node and watchman and now everything seems to work fine.
UPDATE I
It seems that the problem still exists. I have to mension that i'm using sublime text 3. When i restart sublime it seems ok, but after a save it starts reloading again and again. Anyone can help here?
UPDATE II
Removed watchman, falling back to NodeWatcher and all seems ok. But time to time i need to restart sublime text in order to boot up the ember-cli server. That seems to be a known issue...

Ubuntu 14.04 upgrade broke all my virtualenvs

I've seen a couple of fixes for this, but none have worked for me, but I gather that its my virtualenvs that got broken. I just upgraded to 14.04 from 12.04, and now all my pyramid applications no longer work.
When I run ../bin/pserve development.ini, I get the following error:
ImportError: No module named _ctypes
When I run ../bin/python setup.py develop, (also when I try run pshell) I get:
ImportError: No module named _io
I've fixed one project (each pyramid app is in a separate virtualenv) by first removing the old project folder, then reinstalling the virtualenv instance and then copying my scripts back into it. But this is time consuming, and I have several projects.
Is there a quick fix for this?
I've seen removing duplicates of python and simple reinstall of virtualenv, but removing duplicates is not a good option, and the second solution didn't work for me. But maybe I did something wrong there.
I really think that there should be a quick fix for this. Surely reinstalling all virtualenvs cannot be the only solution?
You can simply do
cp /usr/bin/python2 /path/to/my-virtualenv/bin/python2
or
cp /usr/bin/python3 /path/to/my-virtualenv/bin/python3
(Don't need to make a new virtualenv.)
A quick fix that works is to create a new virtualenv and copy its bin/python to the broken virtualenvs. Five simple steps:
mkvirtualenv lero
cd ~/.virtualenvs
for d in */; do cp lero/bin/python $d/bin/python; done
deactivate
rmvirtualenv lero

Can't run cloned repository

How do I download my old code from github? I made a mistake on my app, and when I try to download the old zip file from github and run it I get an error.
I think I'm doing it right, don't I just need to clone the repository? When I do, i get this error when I try to run the server:
An error occurred while installing pg (0.17.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.0'` succeeds before bundling.
and when I run bundel install I still get the error.
I also get this error:
bundle install doesn't work and I still get the error along with this one:Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
It ssems to me that you do not have install Postgres. Install it and try bundle install again.
How install Postgres on Ubuntu (of course you can have another system :) ) - https://help.ubuntu.com/community/PostgreSQL
If you have installed Mavericks, that is the source of your problem. I had to install another gem with native dependencies that needed to be compiled after I installed Mavericks, and some changes as to which compiler Mavericks uses to compile gem dependencies creates problems. In your case, I would suggest you pick one of the solutions in this answer to resolve your PG installation problems.

Symbol not found: _PQbackendPID with Django project

Running on MAC os 10.6.8
with postgresSQL installed, as well django - using python2.7
Also installed psycopg2 and dj-database-url using pip in my virtual env
And added these two lines to my setting.py:
import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
Based on instructions for Heroku in:
https://devcenter.heroku.com/articles/django#database_settings
When running:
python manage.py runserver
I am getting this error:
ImportError: dlopen(/Users.... venv/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID
Referenced from: /Users.... venv/lib/python2.7/site-packages/psycopg2/_psycopg.so
Expected in: dynamic lookup
I kept searching for hours and tried all kind of thing including the advice on:
Mac OS X Lion Psycopg2: Symbol not found: _PQbackendPID
to no avail.
Wonder if anyone had such an issue and had any luck.
I had the same problem. Instead of installing the dependencies as Heroku suggests using
pip install Django psycopg2 dj-database-url
clone whatever repo you're hoping to run in venv, keeping its original settings.py. Then:
source venv/bin/activate
to activate the new environment, cd into your new repo, and python manage.py runserver. Should be set.
Alternatively, you could remake PostGreSQL, and run again, but that's a bit more of a task - it would work for psycopg2, though. As far as I can tell that issue comes from using an 64 or i386 build when you should be using a 32 build - but I'm not sure about this, and the above solution works well to solve the problem and use venv for what you're actually going to be using it for, most likely.
I had the same problem as you guys and I had read many pages and I couldn't find the answer in any of them. Many solution was about installing from source file and don't relate to the virtual environment.
I've found and tested following solution and it solve my problem.
1- Make sure your Postgres is NOT higher than 9.4 version according to psycopg2. Check python version as well. I use Postgres 3.9.9.
2- The problem is behind different version of Python(32/64 bit). It should comply with your operation system's bit architecture which is 64bit. Uninstall all versions of Python and pip from your system. Instruction you can find here but do NOT remove Python2.7 which is Apple-supplied system Python.
3- Install "Mac OS X 64-bit/32-bit" installer from python official website and install it.
After that install pip. Note that you should use the command "python3.5" for using Python version 3.5. You might install virtualenv from the new pip as well.
4- After all that you can go on your virtualenv and type "pip3 install -r requirement.txt" for installing all dependencies on your local machine.
Hope this can help you.