App Deployment: Django not installing on server- AttributeError: 'module' object has no attribute 'lru_cache' - web-deployment

I am trying to deploy a Django App and for some reason, I keep getting this error. It seems to me that Django is not installed but it also errors when installing. Thank you for the help on this. I am deploying on Amazon EC2
(venv) ubuntu#ip----:~/quotes$ pip install Django
Collecting Django
Using cached Django-2.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-ceP6se/Django/setup.py", line 32, in
version = __import__('django').get_version()
File "django/__init__.py", line 1, in
from django.utils.version import get_version
File "django/utils/version.py", line 61, in
#functools.lru_cache()
AttributeError: 'module' object has no attribute 'lru_cache'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ceP6se/Django/

Django has stopped its support for Python 2 version, still you can try installing 1.11 version by using the below code.
pip install Django==1.11

According to the django 2.0 release notes, The Django 1.11.x series is the last to support Python 2.7 (Check it here)
So you can choose to use an older version of Django and then install it with this command:
pip install 'Django<2'
but if you decided to buildup your project using Django>=2.0 then you should create a virtual environment with python 3.4 or higher this way:
sudo apt-get update
sudo apt-get install python3 python3-pip
sudo -H pip3 install virtualenv
mkdir ~/myproject
cd ~/myproject
virtualenv -p `which python3` myprojectenv
source ~/myproject/myprojectenv/bin/activate
python -V
it should output something like this:
Python 3.X.Y
Now you are able to install the latest version of Django without any error:
pip install Django
Good luck,

Related

Python packages required to run RStudio Quarto files in VS Code

I have been trying to run RStudio Quarto script in a fresh Ubuntu 20.04 installation but got into some trouble. Some Python packages that are required to run the simple hello.qmd were not there. I was getting these errors:
MoudleNotFoundError: No module named 'nbclient'
and a second error:
ModuleNotFoundError: No module named 'matplotlib_inline'
The first error was due to I had install the nbclient package. My default Python installation is python2.7. Quarto will not run well with Python 2.7; we should try with 3.7+. If your Linux doesn't come with it by default, this can easily be addressed by installing another Python version and configuring multiple Python versions with the help of the command:
sudo update-alternatives --config python
If no Python version shows up, then it means you have first to configure all your installed Python versions. This is very well explained at https://www.rosehosting.com/blog/how-to-install-and-switch-python-versions-on-ubuntu-20-04/
Once you have configured all your Python versions, every time that you run
sudo update-alternatives --config python, you will be prompted to enter the Python version you want as default. If you have a fresh Ubuntu 20.04, most likely that you have two: Python 2.7 and Python 3.8. Select 3.8 and you will fine. Quarto won't work with Python 2.7.
After you have python3 running and switched into, install nbclient with:
pip install nbclient.
The first error will now pass, but most likely you will get now
ModuleNotFoundError: No module named 'matplotlib_inline'. This is because you also need to install the package matplotlib-inline. This is not documented in the installation instructions of Quarto. But easy to fix. Run:
pip install matplotlib-inline
Now, go back to your VS Code, open the command palette and run Quarto: Render, or just type from the terminal:
quarto preview hello.qmd --no-browser --no-watch-inputs
You are done!

I can't install lableImg Annotation tool in M1 Mac

While installing LabelImg in M1 Mac using below command
pip install pyqt5 lxml
This is the error I got
ERROR: pyqt5 from https://files.pythonhosted.org/packages/7c/5b/e760ec4f868cb77cee45b4554bf15d3fe6972176e89c4e3faac941213694/PyQt5-5.14.0.tar.gz#sha256=0145a6b7de15756366decb736c349a0cb510d706c83fda5b8cd9e0557bc1da72 has a pyproject.toml file that does not comply with PEP 518: 'build-system.requires' contains an invalid requirement: 'sip >=5.0.1 <6'
How to install lableImg annotation tool in M1 Mac?
I got it to work by using the following commands
brew install pyqt#5
pip install labelimg
And that's it, it just works
You just need to type labelimg in the Terminal and the app will start running
I don't know why they don't tell you this in the installation guide
Alrighty!
On MacOS Monterey, none of the other solutions posted here solved this problem for me. However, I managed to easily solve the issue, without a virtual environment or too much fiddling about like so:
Firstly, you have to download all labelImg packages from this link:
https://github.com/tzutalin/labelImg#macos
(You can download it as a .zip file or clone it)
Unzip and then in your terminal cd into whatever directory you downloaded the above files to.
Then run the following commands in order:
pyrcc5 -o libs/resources.py resources.qrc
Then,
pip3 install lxml
Finally,
python3 labelImg.py
It should run without an issue now.
You can go one of two ways:
Using brew:
You can use homebrew to install the dependencies - like qt and libxml2. This will let your package manager handle everything and generally should solve the problem with the . Then you can run
python3 labelimg.py
Using Virtual Environments:
This is the more recommended way to go about in such cases. You can use conda, pipenv or venv to create a virtual environment which is isolated from your system python installation. Then you can try to install it as explained in the README.rst in the root of the repository:
brew install python3
pip3 install pipenv
pipenv run pip install pyqt5==5.12.1 lxml
pipenv run make qt5py3
pipenv run python3 labelImg.py
[Optional] rm -rf build dist; python setup.py py2app -A;mv "dist/labelImg.app" /Applications
You can try the two methods and and get back with the errors if there are any.
This is my note.
I just succeed on my Mac M1 Chip
CHECK THIS OUT!
Installation of labelimg on mac m1 chip
my first reference
my second reference
First, you must use terminal with rosetta version
Then, you already have python3
Then...
[Done]
# check where python3 is
$ where python3
# create env
$ /usr/bin/python3 -m venv env
# check env is
$ where env
# activate env list
$ source env/bin/activate
# updated to the newest
$ pip install --upgrade pip
# installation of PyQt5
$ pip install PyQt5
# start to run labelImg.py
$ cd Documents/repos/labelImg
$ pip3 install pyqt5 lxml
$ make qt5py3
# [run ok!!]
$ python3 labelImg.py
Using Conda
Create a virtual environment in conda and activate it
conda create -n venv
conda activate venv
Install pyqt using conda
conda install pyqt
Install lxml using pip
pip install lxml
Change directory to the downloaded/cloned labelImg folder
cd path/to/labelImg/folder/
Make qt5py3
make qt5py3
Run LabelImg
python labelImg.py

Error while install airflow: By default one of Airflow's dependencies installs a GPL

Getting the following error after running pip install airflow[postgres] command:
> raise RuntimeError("By default one of Airflow's dependencies installs
> a GPL "
>
> RuntimeError: By default one of Airflow's dependencies installs a GPL
> dependency (unidecode). To avoid this dependency set
> SLUGIFY_USES_TEXT_UNIDECODE=yes in your environment when you install
> or upgrade Airflow. To force installing the GPL version set
> AIRFLOW_GPL_UNIDECODE
I am trying to install in Debian 9
Try the following:
export AIRFLOW_GPL_UNIDECODE=yes
OR
export SLUGIFY_USES_TEXT_UNIDECODE=yes
Using export makes the environment variable available to all the subprocesses.
Also, make sure you are using pip install apache-airflow[postgres] and not pip install airflow[postgres]
Which should you use: if using AIRFLOW_GPL_UNIDECODE, airflow will install a dependency that is under GPL license, which means you won't be able to distribute your resulting application commercially. If that's a problem for you, go for SLUGIFY_USES_TEXT_UNIDECODE.
If you are installing using sudo run one of these commands:
sudo AIRFLOW_GPL_UNIDECODE=yes pip3 install apache-airflow
OR
sudo SLUGIFY_USES_TEXT_UNIDECODE=yes pip3 install apache-airflow
NOTE: If pip3 (python3) does not work for you, try pip command.
The pip command can be pointing to python2 or python3 installation depending on your system. Verify this by running pip --version.
Windows users can use the command below before installing apache-airflow:
$ set AIRFLOW_GPL_UNIDECODE=yes
then
$ pip install apache-airflow
In case you are installing the airflow on Windows and through Python terminal then you need to write this:
Set SLUGIFY_USES_TEXT_UNIDECODE=yes
pip install apache-airflow[postgres]
It worked with me after I struggled with trying many other options. Hope this will work with you too.
Below command should install apache-airflow and lets you pull changes into PyCharm for building DAGs and coding for Airflow.
SLUGIFY_USES_TEXT_UNIDECODE=yes
pip install apache-airflow
Also, if you are installing using sudo you can use:
export AIRFLOW_GPL_UNIDECODE='yes'
sudo -E pip3 install apache-airflow
(or use SLUGIFY_USES_TEXT_UNIDECODE)
Run the following command in your python terminal: SLUGIFY_USES_TEXT_UNIDECODE=yes pip install apache-airflow==1.10.0
Use below command to install apache-airflow
sudo SLUGIFY_USES_TEXT_UNIDECODE=yes \
pip install apache-airflow[async,devel,celery,crypto,druid,gcp_api,jdbc,hdfs,hive,kerberos,ldap,password,postgres,qds,rabbitmq,s3,samba,slack]

Cloudbees dev cloud + Capybara-webkit(Qt) how to use?

I want to run capybara-webkit in cloudbees, but I met this error in bundle
SocketCommand.h:4:19: fatal error: QObject: No such file or directory
compilation terminated.
I want to install Qt.
$ sudo apt-get install libqt4-dev
sudo: no tty present and no askpass program specified
$ apt-get install libqt4-dev
apt-get: command not found
How to install Qt? jenkins-plugin?
QT libraries are already installed on DEV#Cloud slaves,
to install capybara gem, you need to set
QMAKE=/usr/bin/qmake-qt4
then run cloudbees ruby add-on script
curl -s -o use-ruby https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/ruby/use-ruby
RUBY_VERSION=1.9.3-p327
source ./use-ruby
and setup your build script to install dependencies
gem install --conservative bundler
bundle install
(or equivalent)

ImportError: No module named haystack

If I install the latest stable 1.2.7 django-haystack with sudo pip install django-haystack, it works fine. But after uninstalling it and installing the very latest dev version 2.0.0 BETA instead as suggested on the main page:
pip install -e git+https://github.com/toastdriven/django-haystack.git#master#egg=django-haystack
Despite the success messages below, it seems like it is not properly installed:
Obtaining django-haystack from git+https://github.com/toastdriven/django-haystack.git#master#egg=django-haystack
Cloning https://github.com/toastdriven/django-haystack.git (to master) to ./src/django-haystack
Running setup.py egg_info for package django-haystack
Installing collected packages: django-haystack
Running setup.py develop for django-haystack
Checking .pth file support in /usr/local/lib/python2.7/dist-packages/
/usr/bin/python -E -c pass
TEST PASSED: /usr/local/lib/python2.7/dist-packages/ appears to support .pth files
Creating /usr/local/lib/python2.7/dist-packages/django-haystack.egg-link (link to .)
Adding django-haystack 2.0.0-beta to easy-install.pth file
Installed /home/kave/projects/cb/src/django-haystack
Successfully installed django-haystack
Cleaning up...
because when I go into the django shell environment and do a
>>> from haystack import indexes
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named haystack
I have followed the instructions and have
INSTALLED_APPS = (... 'haystack',) in there
I had this problem before, but could never solve it. sudo pip install default works fine, but as long as I get the latest Git version, my django doesn't seem to see it.
What could I be missing?
Many Thanks for your advice,
UPDATE
Apologies, but it seems the error is happening only within Aptana Studio 3.0. In Django Shell I can do the import after all. I am still dazzled, as this should be the same. Why can Aptana see the libraries when installing with sudo pip install django-haystack but not if using latest Git version? What could go wrong there please?
UPDATE 2
full sys.path
['/home/kaveh/projects/cb', '/usr/local/lib/python2.7/dist-packages/requests-0.13.9-py2.7.egg', '/home/kaveh/projects/cb/src/django-haystack', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
I finally got it working.
As I said the problem is pip install -e git+https://github.com/toastdriven/django-haystack.git#master#egg=django-haystack is apparently not working.
I simply uninstalled it and made sure its deleted.
Then I simply downloaded the source as zip file, extracted it and
python setup.py build
sudo python setup.py install
This way it will guaranteed be working. Hope this helps someone.

Resources