Install Scipy and Django on AWS ElasticBeanstalk - django

I used the instructions at https://stackoverflow.com/a/20070161/2521204 to activate the virtual environment created by Elastic Beanstalk and https://stackoverflow.com/a/28116352/2521204 to install Numpy and Scipy on a "64bit Amazon Linux 2016.03 v2.1.0 running Python 3.4."
In order to test the installation, I use the following:
python manage.py shell
and inside the Djnago Shell, I use the following:
import numpy
import scipy
I do not receive any error message here. However, when I call
from scipy import stats
in my views.py, it returns the following error message:
ImportError: No module named 'scipy'
I appreciate any help in this regard.

Related

"Import flask from Flask" stops working after deactivating env

already searched database within stockoverflow -- there are no answers to this question!
"Import flask from Flask" stops working after deactivating env
installed python3:
"python3 --version" -->returns Python 3.7.4
installed virtualenv
"pip3 install virtualenv"
"virtualenv env"
"virtualenv --version" --> returns 16.7.4
activated virtual environment
"source env/b/activate" --> creates (env) note at terminal prompt correctly
installed flask in virtual environment
" pip3 install flask"
In the python shell, import flask does not return an error.
python program is:
...
from flask import Flask
app = Flask(__ name __)
#app.route('/')
def hello_world():
- return 'Hello, World!'
...
I get an error!
7. the error is: "unable to import flask"
ANY IDEAS ARE APPRECIATED. THANK YOU
I am using the following to run program:
export FLASK_APP=flask_blog.py
pip show flask --> returns: flask not found
pip3 show flask --> returns: flask version 1.1.1
pip doesn't find flask but pip3 does. What does that mean?
virtualenv venv creates a virtual environment that uses Python 2. Since it isn't using Python 3, pip3 install flask uses the system pip3, which lives outside the virtual environment. This will install Flask outside of the virtual environment.
It's unclear how you're invoking Python. If you're typing python3, if you're getting the system python3, which will be able to import Flask.
Regardless, to correct this, remove venv, and build it again using
virtualenv --python=python3 venv
and then either activate the virtual environment, or use one of the wrappers that that virtual environment provides for you. e.g.,
venv/bin/pip install Flask
then
FLASK_APP=app.py venv/bin/flask run

Why can i use requests in Python shell but i get the error no module found in Django?

I get the error module not found when trying to import requests in Django.
I cannot get python module requests to work in Django. I have installed the module using pip in python and can import in the python terminal.
ModuleNotFoundError: No module named 'requests'
if I run the commands in python shell:
>>> import requests
>>> test = requests.get(url="http://192.168.9.186:2480/connect/test")
i get a htto 204 response but in django I just get the module error
Thanks #H4kor my naive understanding of Python and Django I assumed they were using the same code library. After I ran:
pip install requests
The code ran through and resolved the error. Appreciate the help for this novice.

Installing numpy on openshift origin

I am trying to install numpy on openshift so that my django website can access it. I tried to install it by calling pip install numpy in the pod terminal. This seemed to install but when I tried to import numpy in my code it gave ImportError: No module named numpy
If you are using the OpenShift S2I builder for Python, you would be pointing it at your repository with your application source code. That repo should have a requirements.txt file in it which lists the names of the Python packages you want installed. So create that file and add numpy to it and then trigger a new build and deployment of your application.
If you are not using the Python S2I builder, you need to explain how you are running your application under OpenShift.

Installed python module in google cloud shell but python import is giving ImportError

I have tried installing scipy in Google Cloud Shell. The package is installed, but a python import is giving "ImportError: No module named scipy". Screenshot
I have problem only with scipy. Tensorflow and numpy are all working fine.
This problem should be similar to Installed packages disappeared in Google Cloud Shell.
The problem here is that scipy has not been installed. The process got killed at 99%. This is caused by how pip tries to install the package. I suspect that you're using a small VM instance which has memory limitations when pip tries to load the whole file to memory before installing it.
The solution is to install scipy with this command:
pip --no-cache-dir install scipy
Here you ask pip not to cache the file which should do the trick to install scipy on your Google Cloud VM. After the successful installation you should be able to import the scipy module as intended.

How to import modules into Jupyter notebook

So I am using anaconda and conda in a Windows OS.
And as you may know Jupyter gets installed automatically with Anaconda.
My python code runs normally when using the python command
python myfile.py
However when I try to run it through jupyter I receive the following error
ImportError Traceback (most recent call last)
<ipython-input-1-43605f892034> in <module>()
1 #!/usr/bin/env python
2 import os
----> 3 from gensim import corpora, models, similarities
4 from gensim.models import LsiModel
5 import logging
ImportError: No module named gensim
To troubleshoot I checked the following
Made sure to run jupyter notebook while enabling the activating the proper environment
Made sure the activated envrioment has the "gensim package" installed
So to solve this issue I need to install the missing library through jupyter itself
So I have to add and run the following command in a jupyter cell
pip install --upgrade gensim