I am having trouble installing the package psycopg2 through ebextensions.
00_software.config
packages:
yum:
git: []
htop: []
pip:
psycopg2: []
01_setup_pg_activity.config
commands:
clone:
command: git clone https://github.com/dalibo/pg_activity.git
install_psycopg2:
command: cd pg_activity && python setup.py install
Alternatively, I have also tried this to no avail
commands:
clone:
command: git clone https://github.com/dalibo/pg_activity.git
install_psycopg2:
command: pip install psycopg2
install_psycopg2:
command: cd pg_activity && python setup.py install
The other software installs but pip packages will not
Traceback (most recent call last):
File "/usr/local/bin/pg_activity", line 4, in <module>
__import__('pkg_resources').run_script('pg-activity==1.6.1', 'pg_activity')
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 742, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1510, in run_script
exec(script_code, namespace, namespace)
File "/usr/local/lib/python2.7/site-packages/pg_activity-1.6.1-py2.7.egg/EGG-INFO/scripts/pg_activity", line 42, in <module>
ImportError: No module named psycopg2
I have to manually go in and run sudo pip install psycopg2 for it to correctly install. How can I do this in the build process?
If you are using a virtual environment and EB CLI, simply creating requirements.txt will be enough while the virtual environment is active. EB CLI handles the package installations on deployment.
Using EB with AL2 (python env; haven't tested on RoR), successfully installed pg_activity.
For packages (only psycopg2 shown) I had
packages:
yum:
python-psycopg2: []
And the commands config file was (20_setup_pg_activity.config):
commands:
05_clone:
command: git clone https://github.com/dalibo/pg_activity.git
10_install_pg_activity:
command: cd pg_activity && python setup.py install
Following the env setup, I logged into the EB instance to check if pg_activity exists (only part shown):
ec2-user#ip-172-31-82-127 ~]$ pg_activity --help
Usage: pg_activity [options]
htop like application for PostgreSQL server activity monitoring.
Options:
--version show program's version number and exit
-U USERNAME, --username=USERNAME
Related
I'm having challenges installing django using the command sudo python3.9 -m pip install Django. The error I get running that command is:
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/lib/python3/dist-packages/pip/__main__.py", line 19, in <module>
sys.exit(pip.main())
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 217, in main
return command.main(cmd_args)
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 242, in main
with self._build_session(
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 66, in _build_session
session = PipSession(
File "/usr/lib/python3/dist-packages/pip/download.py", line 321, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/lib/python3/dist-packages/pip/download.py", line 93, in user_agent
zip(["name", "version", "id"], platform.linux_distribution()),
AttributeError: module 'platform' has no attribute 'linux_distribution'
It's been a hard time trying to run sudo python manage.py migrate. From the comment/answer from this Stack Overflow post Traceback while running 'sudo python3 manage.py migrate' I got to know that I need python 3.6 and above. When I created the aws ubuntu server instance I ran python3 -V and the ouput was that python3.5 was running on the machine. I upgraded it to python 3.9. Now when I run python3 -V the output is: Python 3.9.4. After upgrading to python3.9 I created and activated another virtual enviroment.
Now when I try to install django using the command sudo python3.9 -m pip install Django I get the above error. If I use sudo python3 -m pip install Django the django is installed with python3.5 because, thereafter when I run sudo python3 manage.py migrate it throws back an error pointing to File "/usr/lib/python3.5/runpy.py", line 197, in _run_module_as_main If I delete python 3.5 in /usr/lib folder (since I still have python 3.9 there), python3.5 is recreated in the /usr/lib folder whenever I reinstall django using sudo python3 -m pip install Django (even if python3 -V is outputting Python 3.9.4). When I run sudo python3 manage.py migrate it says I don't have django installed in my enviroment variable.
Now the explanation is getting boring. PLEASE HOW DO I INSTALL DJANGO ON UBUNTU AWS USING PYTHON3.9?
sudo apt-get install python3-setuptools
sudo apt remove python3-pip
sudo python3.9 -m easy_install pip
then try to install django again
python3 -m pip install Django
Don't forget to create a virtual environment and specify the python version first
I later found out that it is not possible to run sudo python3.9 -m pip install Django. As stated in the stack overflow post found in the link Traceback while running 'sudo python3 manage.py migrate', python3.5 does not support it.
I had to install python3.6. I was able to use this python version to install django by runnig sudo python3.6 -m pip install Django.
I'm definitely not satisfied with these sorts of breaking changes that exist with python releases, but I'm glad I got the program running.
I am trying to install django using pipenv but failing to do so.
pipenv install django
Creating a virtualenv for this project...
Pipfile: /home/djangoTry/Pipfile
Using /usr/bin/python3.9 (3.9.5) to create virtualenv...
⠴ Creating virtual environment...RuntimeError: failed to query /usr/bin/python3.9 with code 1 err: 'Traceback (most recent call last):\n File "/home/.local/lib/python3.6/site-packages/virtualenv/discovery/py_info.py", line 16, in <module>\n from distutils import dist\nImportError: cannot import name \'dist\' from \'distutils\' (/usr/lib/python3.9/distutils/__init__.py)\n'
✘ Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]:
Failed to create virtual environment.
Other info
python --version
Python 2.7.17
python3 --version
Python 3.6.9
python3.9 --version
Python 3.9.4
pip3 --version
pip 21.1 from /home/aman/.local/lib/python3.6/site-packages/pip (python 3.6)
Please help.Thanks
The problem isn't with installing Django, is on creating your venv, I don't create on this way so I will pass the way that i create
Step 1 - Install pip
Step 2 - Install virtaulEnv
check here how to install both
after installed, run python3 -m venv venvthis wil create an venv on your current directory. Initiate them with . venv/bin/activateand so run pip install django. That should work
Try pipenv install --python 3.9
I'm trying to install a python module called cymysql on a CentOS 6 system by commands like
yum install -y python-setuptools && easy_install pip && pip install cymysql
However I received an Error message saying there're a few lines got SyntaxError: invalid syntax ( see the error code as following)---It actually happened when I run the third command pip install cymysql
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module>
load_entry_point('pip==21.0', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 561, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2631, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2291, in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2297, in resolve
File "/usr/local/lib/python2.7/site-packages/pip-21.0-py2.7.egg/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
Not so sure what's happening here, just wondering if anyone can help? (I enclosed the pip file and main.py here but I don't know where is the init.py file).BTW, It's centOS 6 but I have installed the Python 3.6.10 on the server.When I run the command python3.6 -V, I got
python3.6.10
FIY
PIP file Code:
#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==21.0','console_scripts','pip'
__requires__ = 'pip==21.0'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(
load_entry_point('pip==21.0', 'console_scripts', 'pip')() //**THIS IS LINE 11**
)
Line 57 to 62 in Main.py
try:
cmd_name, cmd_args = parse_command(args)
except PipError as exc:
sys.stderr.write(f"ERROR: {exc}") //**THIS IS LINE 60**
sys.stderr.write(os.linesep)
sys.exit(1)
&tldr;
On an RPM-based distro, you use RPM packages as much as possible.
Never run pip as root user
You must not use pip as root user (or asking for trouble).
There is a whole infrastructure of Python packages installable through yum and this is what you should use.
You can still use pip to install Python modules, but only in very rare cases when a Python module is not available as a package. In that case you must use pip inside a virtual Python environment. Your case is such.
Make sure you have fixed yum for base, EPEL and set up SCLO repositories, since CentOS 6 is EOL.
Then:
# Ensure EPEL repository
yum -y install epel-release
# fix EPEL repo due to EOL:
curl https://www.getpagespeed.com/files/centos6-epel-eol.repo --output /etc/yum.repos.d/epel.repo
yum -y install centos-release-scl-rh
# don't forget to fix repository configuration due to EOL:
curl https://www.getpagespeed.com/files/centos6-scl-eol.repo --output /etc/yum.repos.d/CentOS-SCLo-scl.repo
curl https://www.getpagespeed.com/files/centos6-scl-rh-eol.repo --output /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
# install python 3.6 from Software collection packages (installing virtualenv will pick up both the base python and its pip package)
yum -y install rh-python36-python-virtualenv
Now you can create a virtual environment with any packages from pip, but you have to activate the software collection in your shell first, example:
. /opt/rh/rh-python36/enable
cd ${HOME}
# create "myapp" virtual environment
virtualenv myapp
# install desired packages using virtualenv's pip (will install to the virtualenv and not damage your system)
./myapp/bin/pip install cymysql
Do not go over pip version 20 on a Centos 6 system, otherwise wheels with precompiled c libraries will break.
Long story short, do this first:
pip install --upgrade pip==20.1.0
After that you can install cymysql
I am building a Django project, and I am using GitHub actions to run python manage.py test whenever I push. The problem is that in the project, I am using the graphene-django package, which's available to install via pip install graphene-django. The problem is that, for some reason, this doesn't seem to work (it outputs an error). I have tried everything:
pip install graphene-django
pip install "graphene-django>=2.0"
pip install --user graphene-django
pip install --user "graphene-django>=2.0"
pip3 install graphene-django
pip3 install "graphene-django>=2.0"
pip3 install --user graphene-django
pip3 install --user "graphene-django>=2.0"
Some of these commands display a different error, but the most common is this:
Collecting promise>=2.1 (from graphene-django>=2.0)
Downloading https://files.pythonhosted.org/packages/cf/9c/fb5d48abfe5d791cd496e4242ebcf87a4bb2e0c3dcd6e0ae68c11426a528/promise-2.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-5vr1pems/promise/
Here is my YAML file for the Action (with the last intslling attempt):
name: Testing
on: push
jobs:
test_vote:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Run Django unit tests
run: |
pip3 install --user django
pip3 install --user "graphene-django>=2.0"
python3 manage.py test
env:
# Random key
SECRET_KEY: '!nj1v)#-y)e21t^u#-6tk+%+#vyzn30dp+)xof4q*y8y&%=h9l'
Any help would be really appreciated, since I've been in this for like an hour, when in the course, the teacher took like 5 minutes.
Thanks!
Install the module setuptools before installing graphene-django.
I work on CentOS 6.5 which has by default python 2.6. So I installed manually python 2.7 and set up a sandbox with virtualenv at "/home/thomas/Programs/python-2.7_project".
# Install prerequisites
sudo yum groupinstall "Development tools"
sudo yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel
# Python 2.7.6:
wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
tar xf Python-2.7.6.tar.xz
cd Python-2.7.6
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && sudo make altinstall # IMPORTANT: does not substitute the default python2.6 otherwise many failures will occur (e.g. yum)
# First get the setup script for Setuptools:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
# Then install it for Python 2.7 and/or Python 3.3:
sudo `which python2.7` ez_setup.py
# Now install pip using the newly installed setuptools:
sudo `which easy_install-2.7` pip
# Install virtualenv for Python 2.7 and create a sandbox called my27project:
sudo `which pip2.7` install virtualenv
virtualenv-2.7 /home/thomas/Programs/python-2.7_project # create the new sandbox project into your home directory to install python packages without being in the sudoers list
Then I compiled numpy and scipy as follows:
chmod -R 777 /home/thomas/Programs/python-2.7_project
source /home/thomas/Programs/python-2.7_project/bin/activate
export PYTHONPATH=/home/thomas/Programs/python-2.7_project/lib64/python2.7/site-packages:$PYTHONPATH
sudo yum remove numpy scipy
sudo yum -y install blas lapack atlas atlas-devel mercurial
sudo ln -s /usr/lib64/libblas.so.3 /usr/lib64/libblas.so
sudo ln -s /usr/lib64/liblapack.so.3 /usr/lib64/liblapack.so
sudo ln -s /usr/lib64/atlas/libatlas.so.3 /usr/lib64/atlas/libatlas.so
export BLAS=/usr/lib64/libblas.so
export LAPACK=/usr/lib64/liblapack.so
export ATLAS=/usr/lib64/atlas/libatlas.so
git clone git://github.com/numpy/numpy.git numpy
cd numpy
python setup.py build
python setup.py install --prefix=/home/thomas/Programs/python-2.7_project
# for scipy
pip install cython # necessary for scipy
git clone git://github.com/scipy/scipy.git scipy
cd scipy
python setup.py build
python setup.py install --prefix=/home/thomas/Programs/python-2.7_project
However, I get the following error when I import some functions from scipy.stats:
Traceback (most recent call last):
File "/usr/local/bin/RescoringTK.py", line 66, in <module>
from scipy.stats import pearsonr, linregress, zscore
File "/home/thomas/Programs/python-2.7_project/lib64/python2.7/site-packages/scipy/stats/__init__.py", line 334, in <module>
from .stats import *
File "/home/thomas/Programs/python-2.7_project/lib64/python2.7/site-packages/scipy/stats/stats.py", line 181, in <module>
import scipy.special as special
File "/home/thomas/Programs/python-2.7_project/lib64/python2.7/site-packages/scipy/special/__init__.py", line 546, in <module>
from ._ufuncs import *
ImportError: /home/thomas/Programs/python-2.7_project/lib64/python2.7/site-packages/scipy/special/_ufuncs.so: undefined symbol: npy_exp
Does anyone have any idea about the cause of the error?