How to fix "No module named 'encodings'" in Python3.7.1? - python-3.x

I tried to start uwsgi for myproject(mywords_dict):
uwsgi --http :8000 -H /root/mywords_dict/env --chdir mywords_dict -w mywords_dict.wsgi
But received the following error:
Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
I am so confused that uwsgi can work well if I run it after entering virtual env .Python version of 'mywords_dict' is 3.7.1. I have checked that the there is encoding package in mywords_dic/env. And I can run python successfully from there. Does anyone can help?
*** Starting uWSGI 2.0.18 (64bit) on [Fri Aug 30 00:15:16 2019] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-36) on 29 August
2019 13:49:55
os: Linux-3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018
nodename: VM_0_17_centos
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /root
detected binary path: /root/.pyenv/versions/3.7.1/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to mywords_dict
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 3882
your memory page size is 4096 bytes
detected max file descriptor number: 100001
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8000 fd 4
spawned uWSGI http 1 (pid: 22645)
uwsgi socket 0 bound to TCP address 127.0.0.1:42301 (port auto-assigned) fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.7.1 (default, Nov 11 2018, 01:35:46) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Set PythonHome to /root/mywords_dict/env
**Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'**

This is due to wrong python virtual environment path. It is defined in you .ini file under home variable.
What you need to do is assign to this variable path pointing to the root of your venv. So if your venv path is /home/user/project/venv, just assign this path to the home variable. Be sure not to include the trailing / (slash) in the venv path (since it is later concatenated to /bin/python and you'll end up with double slash.
Then save your .ini file and try starting uWSGI again.

I got the same error.
Fixed after trying these steps :
Uninstall python(38) as administrator. Checking all the boxes during custom installation, including install for all user and precompiling standard library.
Downgrading python38 to 37
I still dont know what & where the error came from though haha.

Related

Issues trying to debug a kernel vmcore

One of our clients called us saying they had had a kernel crash and asked us to investigate. They are running SLES12 SP2.
I copied the vmcore file under /var/crash (11 Mb) out of production, onto another machine also running SLES12 SP2. I copied the image of the kernel /boot/vmlinux-4.4.120-92.70-default.gz too. I installed the kernel debuginfo package in this machine. However I'm unable to run the crash utility on it:
$ strings vmcore |grep "4\.4\."
4.4.120-92.70-default
OSRELEASE=4.4.120-92.70-default
BOOT_IMAGE=/boot/vmlinuz-4.4.120-92.70-default root=[…]
$ strings ~/vmlinux-4.4.120-92.70-default |grep "4\.4\."
Linux version 4.4.120-92.70-default (geeko#buildhost) (gcc version 4.8.5 (SUSE Linux) ) #1 SMP Wed Mar 14 15:59:43 UTC 2018 (52a83de)
$ crash /usr/lib/debug/boot/vmlinux-4.4.120-92.70-default.debug ~/vmlinux-4.4.120-92.70-default vmcore
crash 7.1.5
[…]
GNU gdb (GDB) 7.6
[…]
This GDB was configured as "x86_64-unknown-linux-gnu"...
WARNING: could not find MAGIC_START!
WARNING: cannot read linux_banner string
crash: /usr/lib/debug/boot/vmlinux-4.4.120-92.70-default.debug and vmcore do not match!
Usage: […]
I think the strings invocations above prove that the kernel and the core do match, however I'm still getting that error. What can I do next?

"undefined symbol: mg_free_type" when installing mod_perl 2.0.10 with Apache 2.4.26 and Perl 5.10.1

I'm trying to install mod_perl 2.0.10 for use with a new Apache 2.4 instance. I've got Apache 2.4.26 up and running by itself, but I also need mod_perl installed for a couple of modules to work.
Here's the problem: mod_perl always fails its tests claiming:
Syntax error on line 82 of .../t/conf/httpd.conf: Cannot load .../src/modules/perl/mod_perl.so into server: .../src/modules/perl/mod_perl.so: undefined symbol: mg_free_type
The only information I could find on this is here: Error when installing mod_perl2. Unfortunately, it didn't solve the problem.
Using CentOS release 6.8 (Final)
x86_64 x86_64 x86_64 GNU/Linux
More from the log:
> make test
cd "src/modules/perl" && make
make[1]: Entering directory `/software/apa/mod_perl/mod_perl-2.0.10/src/modules/perl'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/software/apa/mod_perl/mod_perl-2.0.10/src/modules/perl'
...
make[1]: Leaving directory `/software/apa/mod_perl/mod_perl-2.0.10/xs'
/usr/bin/perl -Iblib/arch -Iblib/lib \
t/TEST -clean
[warning] setting ulimit to allow core files
ulimit -c unlimited; /usr/bin/perl /software/apa/mod_perl/mod_perl-2.0.10/t/TEST -clean
APACHE_TEST_APXS= APACHE_TEST_GROUP= APACHE_TEST_HTTPD= APACHE_TEST_PORT= APACHE_TEST_USER= \
/usr/bin/perl -Iblib/arch -Iblib/lib \
t/TEST -bugreport -verbose=0
[warning] setting ulimit to allow core files
ulimit -c unlimited; /usr/bin/perl /software/apa/mod_perl/mod_perl-2.0.10/t/TEST -bugreport -verbose=0
/software/apa/apa24/bin/httpd.prefork -d /software/apa/mod_perl/mod_perl-2.0.10/t -f /software/apa/mod_perl/mod_perl-2.0.10/t/conf/httpd.conf -D APACHE2 -D APACHE2_4 -D PERL_USEITHREADS
using Apache/2.4.26 (prefork MPM)
waiting 300 seconds for server to start: .httpd.prefork: Syntax error on line 82 of /software/apa/mod_perl/mod_perl-2.0.10/t/conf/httpd.conf: Cannot load /software/apa/mod_perl/mod_perl-2.0.10/src/modules/perl/mod_perl.so into server: /software/apa/mod_perl/mod_perl-2.0.10/src/modules/perl/mod_perl.so: undefined symbol: mg_free_type
[ error]
server has died with status 255 (t/logs/error_log wasn't created, start the server in the debug mode)
sh: line 1: 3359 Terminated /usr/bin/perl /software/apa/mod_perl/mod_perl-2.0.10/t/TEST -bugreport -verbose=0
make: *** [run_tests] Error 143
This bug was introduced when they added support of perl version 5.22, in mod_perl 2.0.10: https://github.com/apache/mod_perl/commit/82827132efd3c2e25cc413c85af61bb63375da6e#diff-0a249c57fb8151f85647e167a883be1b
And then was fixed in a mod_Perl patch on 4 January 2018 (2.0.11-dev):
https://github.com/apache/mod_perl/commit/f4d886fdf7d79d54a0647336b5623b840a053eab
To fix this problem you must compile from source of this commit of mod_perl 2.0.11-dev (or the trunk version) to fix the problem if you have perl <=5.13.6, or if you can upgrade Perl to version >5.13.6 you can compile with mod_perl 2.0.10.
This change in Perl as been introduced in source of Perl version 5.13.6 in this perl commit :
https://perl5.git.perl.org/perl.git/commit/d908838680ec40ea0e85f59ee66f5f56a225f9b4
The mod_perl fix (in last 2.0.11-dev) in src/modules/perl/modperl_env.c use contextual usage of mg_free to fix the problem :
#if MP_PERL_VERSION_AT_LEAST(5, 13, 6)
mg_free_type((SV*)ENVHV, PERL_MAGIC_env);
#else
mg_free((SV*)ENVHV);
#endif
I solved this by upgrading to Perl 5.14.0 or newer.
In the Perl documentation, mg_free_type first appears in version 5.14.0. You can see under "Magical Functions" where it isn't listed in 5.12.4 but is in 5.14.0
I'm not sure if this is the correct solution as mod_perl2.0 lists Perl 5.6.1 as the minimum version: https://perl.apache.org/docs/2.0/user/install/install.html#item_Perl

uwsgi options --wsgi-file and --module not recognized

I am trying to run a Django app using uwsgi. Most instructions I have found refer to a "--wsgi-file" and "--module" to specify the application, but "uwsgi" makes no mention of these options, and when I try and use them:
uwsgi -s /tmp/uwsgi.sock --master --module myapp.wsgi
uwsgi: unrecognized option '--module'
getopt_long() error
And
uwsgi -s /tmp/uwsgi.sock --master --wsgi-file myapp/wsgi.py
uwsgi: unrecognized option '--wsgi-file'
getopt_long() error
When I run it without either, I get:
uwsgi -s /tmp/uwsgi.sock --master
*** Starting uWSGI 2.0.9 (64bit) on [Fri Jul 10 11:12:04 2015] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-11) on 23 April 2015 19:31:15
os: Linux-2.6.32-504.16.2.el6.x86_64 #1 SMP Tue Mar 10 17:01:00 EDT 2015
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
detected binary path: /usr/sbin/uwsgi
your processes number limit is 1024
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 5
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145536 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 26597)
spawned uWSGI worker 1 (pid: 26598, cores: 1)
Why aren't these options recognized? How am I supposed to specify the app to load? What kind of garbage software is this? Should I go back to using Gunicorn?
This means that the python plugin for uWSGI isn't installed or loaded. To verify run:
$ uwsgi --plugins-list
In general if you have build-essential python-dev etc., you can install via:
$ pip install uwsgi
On Debian or Ubuntu you can also install it via:
$ apt-get install uwsgi-plugin-python
On Linux Alpine you currently have to specify where it is:
$ apk add --update uwsgi-python
$ uwsgi --plugins-dir /usr/lib/uwsgi/ --need-plugin python --plugins-list
*** uWSGI loaded generic plugins ***
*** uWSGI loaded request plugins ***
0: python
...
Alternatively you can specify its full path via:
$ uwsgi --plugin /usr/lib/uwsgi/python_plugin.so --plugins-list
Depending how you installed uwsgi also might also need to install the python plugin. e.g.
apt-get install uwsgi-plugin-python

Problems to start G-WAN

I try to install G-Wan on Ubuntu 12.04.1 LTS (x64).
I follow the fast instructions: http://gwan.com/download
When i execute $sudo ./gwan, shows me:
Floating point exception (core dumped)
Then i follow the slow instructions: http://www.as2.com/pdf/GWAN-Install-Manual-for-Ubuntu-12.04.pdf
but i have the same error.
I show you the errors of the logs:
apport.log
ERROR: apport (pid 13912) Mon Apr 29 13:42:56 2013: called for pid 13870, signal 8
ERROR: apport (pid 13912) Mon Apr 29 13:42:56 2013: executable: /opt/gwan_linux64-bit/gwan (command line "./gwan")
ERROR: apport (pid 13912) Mon Apr 29 13:42:56 2013: executable does not belong to a package, ignoring
syslog
Apr 29 13:43:48 ip-10-34-153-82 kernel: [1026847.541495] gwan[13914] trap divide error ip:427930 sp:7fff7208d7b8 error:0
Apr 29 13:43:53 ip-10-34-153-82 kernel: [1026852.993012] gwan[13958] trap divide error ip:427930 sp:7fffd2b82468 error:0
Please, Does anyone know what is the problem?
Install the program in my PC (Ubuntu 12.04.2 LTS) and works fine, i don't understand because in my PC works fine and in the server not.
Thanks for all and sorry, my english is bad.
The problem is that some newer versions of hypervisors insist to report ZERO CPU, and/or ZERO CPU Core, leading to a division by zero.
Since G-WAN is optimized for multicore architectures, it queries the CPUID instruction and the OS Kernel structures to check the platform architecture and the associated OS policies (number of online and allowed CPUs).
Other web servers are not affected because they expect users to manually configure and run as many instances as desired (hereby creating the duplicated resource allocations that G-WAN was designed to avoid).
Checking both the CPUID instruction and the Kernel structure was enough, until recently. Now, for any reason, the hypervisors use broken CPUID implementations and OS Kernel structure.
This issue is affecting hosting companies (VPS servers), and Amazon EC2 instances, among others.

libstdc++.so.6: cannot handle TLS data

I have an application compiled at:
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Linux debian 2.6.18-5-686 #1 SMP Fri Jun 1 00:47:00 UTC 2007 i686 GNU/Linux
and it runs well.
Now I want to run it at:
Linux 2.4.20_mvlcge31-tomas #7 Thu May 7 11:33:21 CEST 2009 i686 unknown
I got following errors:
libstdc++.so.6: cannot handle TLS data
From the web I saw someone suggested to do this: export LD_ASSUME_KERNEL=2.2.5
I tried but get even more errors:
ls: error while loading shared libraries: librt.so.1: cannot open shared object file: No such file or directory
Who can help me with it? thanks
You had compiled the application against much newer libc and kernel version, You can't compile program on 2.6 with newest libc and expect it to run on old kernel.
Also where do you actually still use Linux 2.4?

Resources