zhaoweih/Shadowsocks-Tutorial

[Error] Failed to install python

jykqwer opened this issue · 12 comments

设置好加密方式后出现
Which cipher you'd select(Default: aes-256-cfb):

cipher = aes-256-cfb

Press any key to start...or Press Ctrl+C to cancel
[Info] Checking the EPEL repository...
[Info] Checking the EPEL repository complete...
[Info] Starting to install package unzip
[Info] Starting to install package gzip
[Info] Starting to install package openssl
[Info] Starting to install package openssl-devel
[Info] Starting to install package gcc
[Info] Starting to install package python
[Error] Failed to install python
Please visit: https://teddysun.com/486.html and contact.
[root@vultr ~]#

怎么解决

安装python失败了,可以先安装好python再安装shadowsocks,或者尝试备用教程:https://github.com/zhaoweih/Shadowsocks-Tutorial/blob/master/super_easy_shadowsocks_tutorial.md

请问这个问题解决了吗

[Info] Checking the EPEL repository...
[Info] Checking the EPEL repository complete...
[Info] Starting to install package unzip
[Info] Starting to install package gzip
[Info] Starting to install package openssl
[Info] Starting to install package openssl-devel
[Info] Starting to install package gcc
[Info] Starting to install package python
[Error] Failed to install python
Please visit: https://teddysun.com/486.html and contact.
[root@vultr ~]#

can someone help me. I also have that trouble

pbgf commented

maybe is centos8,i change os to centos7 and this problem is sloved

maybe is centos8,i change os to centos7 and this problem is sloved
change the depends as follow, seems centos 8's yum change the python versions
yum_depends=(
unzip gzip openssl openssl-devel gcc python36 python36-devel python3-setuptools pcre pcre-devel libtool libevent
autoconf automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel
libev-devel c-ares-devel git qrencode
)

maybe is centos8,i change os to centos7 and this problem is sloved
change the depends as follow, seems centos 8's yum change the python versions
yum_depends=(
unzip gzip openssl openssl-devel gcc python36 python36-devel python3-setuptools pcre pcre-devel libtool libevent
autoconf automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel
libev-devel c-ares-devel git qrencode
)

works fine.

maybe is centos8,i change os to centos7 and this problem is sloved

I think that's possible, because my another sever which is CentOS 7 don't have this problem.

安装python失败了,可以先安装好python再安装shadowsocks,或者尝试备用教程:https://github.com/zhaoweih/Shadowsocks-Tutorial/blob/master/super_easy_shadowsocks_tutorial.md

Link is failed

链接用不了

安装python失败了,可以先安装好python再安装shadowsocks,或者尝试备用教程:https://github.com/zhaoweih/Shadowsocks-Tutorial/blob/master/super_easy_shadowsocks_tutorial.md

Link is failed

链接用不了

Sorry, the article was temporarily hidden due to some outdated content. It has been restored now.

把shad***socks.all.sh文件中的python(53个)改成 python3,因为centos8已经不识别 python

Encounter same problem on ubuntu 22.04. Found solution if you can't change server's OS (i used installation script from Teddysun, if your installation journey is different, this will probably not help.)

Please let me know if this is not a correct place for such information and i will move my answer to different repo/issue.

  1. when you will run shadowsocks-all.sh, you probably will not be able to install 'python' because its python 2.7 and it is deprecated by it's name (tho python 2.7 is usually installed). You can change deps in file like so:
# before
apt_depends=(
       gettext build-essential unzip gzip python3 python3-dev python3-setuptools curl openssl libssl-dev
       autoconf automake libtool gcc make perl cpio libpcre3 libpcre3-dev zlib1g-dev libev-dev libc-ares-dev git qrencode
   )

# after
apt_depends=(
            gettext build-essential unzip gzip python3 python3-dev python3-setuptools curl openssl libssl-dev
            autoconf automake libtool gcc make perl cpio libpcre3 libpcre3-dev zlib1g-dev libev-dev libc-ares-dev git qrencode
        )
  1. After this you will be able to install ShadowsocksR successfuly, but it will fait to load, because of few reasons:
    2.1) Some files uses old python's syntax, and it will need to be updated.
    2.2) 'find_library' in shadowsocks/crypto/util.py will probably fail to find 'libcrypto', even tho it is linked properly.

I solved everything like this:
2.1)
In /usr/local/shadowsocks/lru_cache:
MutableMapping for LRUCache class should come from collections.abc, not from collections:

# before
import collections
class LRUCache(collections.MutableMapping):
    # insides

# after
from collections.abc import MutableMapping
class LRUCache(MutableMapping):
    # insides

In /usr/local/common.py:

if addr is "": # line 266 for me (not correct for python3)
if addr == "": # correct

if len(block) is 1: # line 279 for me (not correct for python3)
if len(block) == 1: # correct

while (ip & 1) == 0 and ip is not 0: # line 281 for me (not correct for python3)
while (ip & 1) == 0 and ip != 0: # correct

if addr_family is socket.AF_INET: # line 291 for me (not correct3)
if addr_family == socket.AF_INET # correct

if addr_family is socket.AF_INET: # line 298 for me (not correct3)
if addr_family == socket.AF_INET: # correct

At this point i thought that everything will work now. You can try at this point:
/etc/init.d/shadowsocks-r start

And i got new error:

Traceback (most recent call last):
  File "/usr/local/shadowsocks/server.py", line 221, in <module>
    main()
  File "/usr/local/shadowsocks/server.py", line 39, in main
    config = shell.get_config(False)
  File "/usr/local/shadowsocks/../shadowsocks/shell.py", line 303, in get_config
    check_config(config, is_local)
  File "/usr/local/shadowsocks/../shadowsocks/shell.py", line 132, in check_config
    encrypt.try_cipher(config['password'], config['method'])
  File "/usr/local/shadowsocks/../shadowsocks/encrypt.py", line 46, in try_cipher
    Encryptor(key, method)
  File "/usr/local/shadowsocks/../shadowsocks/encrypt.py", line 90, in __init__
    self.cipher = self.get_cipher(key, method, 1,
  File "/usr/local/shadowsocks/../shadowsocks/encrypt.py", line 120, in get_cipher
    return m[2](method, key, iv, op)
  File "/usr/local/shadowsocks/../shadowsocks/crypto/openssl.py", line 98, in __init__
    load_openssl()
  File "/usr/local/shadowsocks/../shadowsocks/crypto/openssl.py", line 39, in load_openssl
    libcrypto = util.find_library(('crypto', 'eay32'),
  File "/usr/local/shadowsocks/../shadowsocks/crypto/util.py", line 80, in find_library
    path = ctypes.util.find_library(name)
  File "/usr/lib/python3.10/ctypes/util.py", line 341, in find_library
    _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
  File "/usr/lib/python3.10/ctypes/util.py", line 147, in _findLib_gcc
    if not _is_elf(file):
  File "/usr/lib/python3.10/ctypes/util.py", line 99, in _is_elf
    with open(filename, 'br') as thefile:
FileNotFoundError: [Errno 2] No such file or directory: b'liblibcrypto.a' 

This is p.2.2 of problems that i encounter. This probably happens because /usr/local/shadowsocks/crypto/openssh.py calls find_library() and unable to get all 'expected libraries', even tho it can proceed with any found by 'expected name'.

To fix this exact problem, in /usr/local/shadowsocks/crypto/util.py:

# before:
def find_library(possible_lib_names, search_symbol, library_name):
    # some part of the function before
    for name in lib_names:
        if os.name == "nt":
            paths.extend(find_library_nt(name))
        else:
            path = ctypes.util.find_library(name)
            if path:
                paths.append(path)

    if True:
        # rest of the function


# Change to this:
def find_library(possible_lib_names, search_symbol, library_name):
    # some part of the function before
    for name in lib_names:
        if os.name == "nt":
            paths.extend(find_library_nt(name))
        else:
            # wrap problematic part in try/except
            try:
                path = ctypes.util.find_library(name)
            except Exception:
                pass
            if path:
                paths.append(path)

After those stages i was able to start server with command above:
/etc/init.d/shadowsocks-r start

This is not even close to be 'ideal' or 'clean' solution, and you also might have another kind of errors, but if you can't change server's OS or have exactly the same problem this could help.

Please note, that in my 'solution' i've patched only the problematic parts that i see for now, had too little time to inspect whole package and rewrite it to python3, so it is totally possible that some other parts of the code also needs to be updated or another bugs might arise, but i hope my little adventure will help somebody to overcome problems and give a hint on how it is possible to solve them.