My main OS is windows 10 but I am using cygwin as a terminal. While installing uwsgi through pip3 install uwsgi command , it fails with an error message " AttributeError: module 'os' has no attribute 'uname'"
uWSGI needs a c compiler to build and the os.uname to use platform.uname needs to be updated in the uwsgiconfig.py file.
Here is how to fix for windows 10:
cd to uwsgi install directory and open uwsgiconfig.py
replace os.uname with platform.uname for the following lines of code:
uwsgi_os = os.uname()[0]
uwsgi_os_k = re.split('[-+_]', os.uname()[2])[0]
uwsgi_os_v = os.uname()[3]
uwsgi_cpu = os.uname()[4]
to this:
uwsgi_os = **platform.uname**()[0]
uwsgi_os_k = re.split('[-+_]', **platform.uname**()[2])[0]
uwsgi_os_v = **platform.uname**()[3]
uwsgi_cpu = **platform.uname**()[4]
Install the following packages with cygwin to make sure you have python3 and gcc available for cygwin terminal and not just python installed on windows. This is a separate python install than for windows itself.
Open windows cmd terminal
cd to cygwin64 (or your install dir)
run this command:
setup-x86_64.exe -q -P wget -P gcc-g++ -P gcc-core -P gcc-g++ -P libcrypt-devel -P libintl-devel -P python3 -P python3-devel
This command should install the following packages for Cygwin64:
gcc-core
gcc-g++
libcrypt-devel
libintl-devel
python3
python3-devel
In Cygwin terminal window
cd to uwsgi directory
type and run command 'python3 setup.py install'
wait for this to finish and do a happy dance.
If you get:
core/event.c: In function ‘event_queue_read’: core/event.c:1416:9: error: ‘UWSGI_EVENT_IN’ undeclared
probably you don't start setup install with cygwin python
Code need to be changed a bit to:
import platform
uwsgi_os = platform.uname()[0]
uwsgi_os_k = re.split('[-+_]', platform.uname()[2])[0]
uwsgi_os_v = platform.uname()[3]
uwsgi_cpu = platform.uname()[4]
Related
Problem:
I want to get the python3 path in my Ubuntu VM. Like /usr/xyz/python3
More Information:
I dont see the 'which' command present in my envt.
I tried to 'sudo apt install which', but it fails saying that no such package found.
Get path of the executable python binary
Python code
import sys
print(sys.executable)
Command
python -c "import sys; print(sys.executable)"
sudo apt install which is failing because which is part of debianutils; most executables don't come as their own package.
sudo apt install debianutils
If you use bash, you can just do :
type -p python
The where and which commands are often an alias to the inbuilt bash command type.
I have it also as app in busybox on most embedded devices.
Also tablets and smartfons with the app: ConnectBot
If present on your machine too; then: type -p python3
But anyway, the correct/recommended way to make a SHEBANG is not to use type, where or which.
If your PATH environment variable targets the usually folders for installed executables just use: #!/usr/bin/env python3
Example: test.py
#!/usr/bin/env python3
import sys
print('No error - But i return 1 and not 0')
sys.exit(1)
Making than executable with: chmod +x test.py
And execute it...
$ ./test.py
No error - But i return 1 and not 0
I run through the following steps to attempt to start up an app for production:
-Setup a virtualenv for the python dependencies: virtualenv -p /usr/bin/python3.8 ~/app_env
-Install pip dependencies: . ~/app_env/bin/activate && pip install -r ~/app/requirements.txt
-Un-comment the lines for privilege dropping in uwsgi.ini and change the uid and gid to your account name
-Login to root with sudo -s and re-source the env with source /home/usr/app_env/bin/activate
-Set the courthouse to production mode by setting the environment variable with export PRODUCTION=1
-Start the app: cd /home/usr/app && ./start_script.sh
And I get the following error:
(app_env) root#usr-Spin-SP314-53N:/home/usr/Desktop/app# ./start.sh
uwsgi: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
I tried a few things such as installing a newer libpcre version like mentioned here, tried also the steps mentioned here but that didn't work. Also the environment I'm setting up doesn't use anaconda but regular python. I even tried pip install uwsgi in my virtual env but it said the requirement was already satisfied. I'm not much of an expert when it comes to somewhat complex package management like this, help with how to solve this would be greatly appreciated. Thanks. I'm on Ubuntu 20.04, using python 3.8.
What solved it for me was apparently just reinstalling UWSGI, like in this thread, in my virtual env while forcing it to ignore the cache so it could know to use the pcre library I installed.
In order, doing this
uwsgi --version
Was giving me this
uwsgi: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
So I made sure I had the latest libpcre installed
sudo apt-get install libpcre3-dev
And then what linked it all together was this
pip install uwsgi -I --no-cache-dir
I tried to solve this error but it did not work no matter what I did and then reinstalled uwsgi, but the following 2 lines solved my problem
sudo find / -name libpcre.so.*
#change the path of the /home/anaconda3/lib/libpcre.so.1 with the one appears after above one.
sudo ln -s /home/anaconda3/lib/libpcre.so.1 /lib
which python
I'm trying to install GDAL to use with Python 3 on an AWS EC2 Amazon2 machine (RHEL7).
Following the instructions on this page: Install GDAL on Python 2.7 on a Amazon Linux virtual server I managed to get it working for python 2.7 ("import gdal from osgeo" works).
However, I need it to work for python3 installed on my machine. I tried to adjust the instructions accordingly, and got to this set of commands:
sudo yum-config-manager --enable epel
sudo yum -y install make automake gcc gcc-c++ libcurl-devel proj-devel geos-devel gdal-devel gdal-python python3-devel
sudo yum -y update
cd /tmp
curl -L http://download.osgeo.org/gdal/2.4.0/gdal-2.4.0.tar.gz | tar zxf -
cd gdal-2.4.0/
./configure --prefix=/usr/local --with-python
sudo make -j4
sudo make install
python3 -m pip install numpy --user
sudo -H pip3 install --upgrade pip
CPLUS_INCLUDE_PATH=/usr/include/gdal
C_INCLUDE_PATH=/usr/include/gdal
sudo python3 -m easy_install GDAL -d /usr/lib/python3.7/site-packages --include-dirs=/usr/include/gdal
when I run the last command, the installation tries to run but fails with:
"error: command 'gcc' failed with exit status 1".
There are many errors before that, such as:
/usr/local/include/cpl_vsi_error.h:58:24: error: ‘CPL_FORMAT_STRING’ has not been declared
CPL_FORMAT_STRING(const char *fmt), ... )
^~~~~~~~~~~~~~~~~
In file included from extensions/gdal_wrap.cpp:3173:0:
From what I gather, the gcc can't find the GDAL headers, but it is specified in the command and I also did the including commands above:
CPLUS_INCLUDE_PATH=/usr/include/gdal
C_INCLUDE_PATH=/usr/include/gdal
Any ideas will be helpful!
I installed python 3x via home brew, the process was successful.
However when I check version, it shows 2x
here is the terminal output
➜ ~ brew install python
Warning: python 3.7.2 is already installed, it's just not linked
You can use `brew link python` to link this version.
➜ ~ brew link python
Linking /usr/local/Cellar/python/3.7.2... Error: Permission denied # dir_s_mkdir - /usr/local/Frameworks
➜ ~ sudo brew link python
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
➜ ~ python -V
Python 2.7.10
I think I need to modify some kind of path. And do some magic then pray...lol
Anyway anyone know how to get this work on my machine? I'm mac latest
First, solve your permission problem by running the official command from the Homebrew Documentation, Troubleshooting page
cd /usr/local && sudo chown -R $(whoami) bin etc include lib sbin share var opt Cellar Caskroom Frameworks
Then run brew link python
And finally run echo $PATH and check that your /usr/local/bin has precedence over other directories.
you could do brew uninstall python3 and install it from the python website here https://www.python.org/
When you go install a module you do pip3 install packageName
And when you run a program you could run it from your IDE (I recommend VSCode) or run it from the terminal with python3 drag_python_file_here
you have to use python3 instead of python on Mac so like python3 path/to/file.py and pip is now pip3 so like pip3 install pillow
Linux Mint 17 with Python 3.5.1
$ python3 -m venv ENV_DIR
returns:
Error: Command '['/home/path/to/ENV_DIR/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
I have tried various ways to get the terminal to show I am in a venv with no success.
That's due to a bug in Ubuntu 14.04 (on which Linux Mint 17 is based)
You can either create the virtual environment without pip and then manually install it inside the environment:
$ python3 -m venv --without-pip my_venv
$ source my_venv/bin/activate
(my_venv)$ curl https://bootstrap.pypa.io/get-pip.py | python
Or you can manually install ensurepip in your system, by adapting these instructions to Python 3.5.1:
cd /usr/lib/python3.5
sudo mkdir -p ensurepip/_bundled
cd ensurepip
sudo wget https://github.com/akheron/cpython/raw/v3.5.1/Lib/ensurepip/__init__.py
sudo wget https://github.com/akheron/cpython/raw/v3.5.1/Lib/ensurepip/__main__.py
sudo wget https://github.com/akheron/cpython/raw/v3.5.1/Lib/ensurepip/_uninstall.py
cd _bundled
sudo wget https://github.com/akheron/cpython/raw/v3.5.1/Lib/ensurepip/_bundled/pip-1.5.4-py2.py3-none-any.whl
sudo wget https://github.com/akheron/cpython/raw/v3.5.1/Lib/ensurepip/_bundled/setuptools-