0%

最后一天折腾汇总

Windows10下安装Anaconda3(64位)详细过程

下载地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

https://blog.csdn.net/ychgyyn/article/details/82119201

https://www.jianshu.com/p/1f94ff0c6e68

conda安装celery

https://blog.csdn.net/weixin_30760895/article/details/101983Ubuntu538

coda指定安装路径3.5.2

https://www.cnblogs.com/lemonbit/p/7068091.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Anaconda创建环境:

//下面是创建python=3.6版本的环境,取名叫py36

conda create -n py36 python=3.6 

 

删除环境(不要乱删啊啊啊)

conda remove -n swzl --all

 查看所有的虚拟环境
conda env list

激活环境

//下面这个py36是个环境名

source activate py36  (conda4的是:conda activate py36)


conda create --help
安装虚拟环境到指定路径的命令如下:
conda create --prefix=O:\Python\SWZL\venv -n python=3.5.2
激活虚拟环境
conda activate O:\Python\SWZL\venv
退出虚拟环境的命令如下:
deactivate
删除虚拟环境
conda remove --p=O:\Python\SWZL\ -n venv --all

查找指定版本的包

https://blog.csdn.net/ksws0292756/article/details/79192268

conda安装源更换

https://blog.csdn.net/ffscript/article/details/78447197

1
2
3
anaconda search -t conda celery
anaconda show prometeia/celery
conda install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
pipenv+anaconda创建虚拟环境
pipenv --python D:\ProgramData\Anaconda3\pkgs\python-3.5.2-0\python.exe
更新 pypi源来提高依赖库安装的速度
在使用pipenv的时候,常常会在安装的时候,一直卡在了 Locking 这里,通过加上 -v 参数,可以看到安装过程中的步骤信息,卡在了下载那里,这时应该可以意识到是因为网络的原因,pipenv创建的 Pipfile 中默认的pypi源是python官方的 https://pypi.python.org/simple。我们国内用户访问下载的时候会很慢。
https://vimiix.com/post/2018/03/11/manage-your-virtualenv-with-pipenv/
所以,我一般会在创建好Pipfile以后,修改到文件中 source 块下的 url 字段,设置为国内的 pypi 源就好了,我推荐的是清华的pypi源,具体设置如下:

备注:我还没有找到如何修改能在创建时就设好的方法,应该修改源码是可以的,但这样不尊重源码,毕竟高墙是我们自己筑起的,如果有好的方法,您不妨在评论中告诉我一下
[[source]]

url = "https://pypi.tuna.tsinghua.edu.cn/simple"
verify_ssl = true
name = "pypi"

虚拟环境位置

Pipenv 生成的虚拟环境默认在用户目录, 你可以通过设置环境变量: PIPENV_VENV_IN_PROJECT=1 来使生成的虚拟环境位于项目目录.
Windows-x64 10
Celery 3.1.23
Celery-with-redis 3.0
Redis-win32-win64 2.4.5
1
2
pip install celery==3.1.15
pip install redis==2.10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
FROM python:3.5
MAINTAINER iBoy "547142436@qq.com"
COPY requirements.txt /root/www/app/
WORKDIR /root/www/app
CMD ["python"]
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

Flask + Docker 无脑部署新手教程

https://zhuanlan.zhihu.com/p/78432719

构建文件
docker build -t flask-sample:latest .

sudo docker run -it --rm -p 80:80 testflask

pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

修改默认指向方式
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
更改Linux Python镜像
cd ~
mkdir .pip
cd .pip
vim pip.conf

[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn


生成纯净的依赖
第二种 (推荐) 使用 pipreqs ,github地址为: https://github.com/bndr/pipreqs

# 安装
pip install pipreqs
# 在当前目录生成
pipreqs . --encoding=utf8 --force
注意 --encoding=utf8 为使用utf8编码,不然可能会报UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 406: illegal multibyte sequence 的错误。

--force 强制执行,当 生成目录下的requirements.txt存在时覆盖。

当当当,可以看见我依赖的只有这些啦
python3 run.py --host=0.0.0.0 --port=8888 --no-reload
celery worker -A run.celery -l DEBUG -E
celery worker -A app.celery -l DEBUG -E

pip3 install gunicorn
python3 run.py --host=0.0.0.0 --port=8889 --no-reload
sudo apt-get install gunicorn
gunicorn -b 0.0.0.0:8889 run:app
pip3 install -U git+https://github.com/benoitc/gunicorn.git

export C_FORCE_ROOT="True"
1
redis允许外部连接 https://www.cnblogs.com/sheseido/p/11239137.html
1
2
3
4
5
6
Ubuntu包管理工具更改
解决Ubuntu 无法用 apt-get install 安装任何软件
https://www.codelast.com/%E5%8E%9F%E5%88%9B-%E8%A7%A3%E5%86%B3ubuntu-%E6%97%A0%E6%B3%95%E7%94%A8-apt-get-install-%E5%AE%89%E8%A3%85%E4%BB%BB%E4%BD%95%E8%BD%AF%E4%BB%B6dpkg-error-processing-package-xxx%E7%9A%84%E9%97%AE/

wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.6.12_amd64.deb
dpkg -i apt_1.6.12_amd64.deb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
安装Redishttps://juejin.im/entry/5bac46dd5188255c960c3d27
sudo apt-get install redis-server
检查进程
ps -agx|grep redis
检查启动
netstat -nlt|grep 6379
检查状态
sudo /etc/init.d/redis-server status
redis-cli
Redis服务器的配置文件redis.conf
sudo vim /etc/redis/redis.conf
vim 搜索
命令模式下 /127.0.0.1
按下n查找下一个,按下N查找上一个。

如果是用apt-get或者yum install安装的redis,可以直接通过下面的命令停止/启动/重启redis

/etc/init.d/redis-server stop
/etc/init.d/redis-server start
/etc/init.d/redis-server restart

如果是通过源码安装的redis,则可以通过redis的客户端程序redis-cli的shutdown命令来重启redis

1.redis关闭
redis-cli -h 127.0.0.1 -p 6379 shutdown

2.redis启动
redis-server

如果上述方式都没有成功停止redis,则可以使用终极武器 kill -9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Ubuntu18.04换源
sudo mv /etc/apt/sources.list /etc/apt/sourses.list.backup
vim /etc/apt/sources.list
#清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

#3 更改完成之后执行以下命令
sudo apt-get update
sudo apt-get upgrade。
mysqlclient无法安装解决
sudo apt-get install python3.6-dev
mysqlclinet安装报错https://blog.ducthinh.net/gcc-no-such-file-python-h/


2、允许mysql远程访问,可以使用以下三种方式:
a、改表。
mysql -u root –p
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;


Ubuntu18.04安装MySQL Server
Ok, I solved in this way:

I used Software & Updates application to remove mariadb sources
and executed the followings steps (ref https://askubuntu.com/a/934576):
sudo apt purge mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7 mysql-server
sudo apt update && sudo apt dist-upgrade && sudo apt autoremove && sudo apt -f install
sudo apt install mysql-server

终端连接MySQL
mysql -h 192.168.19.1 -u root -p

安装MYSQL-python
ip install configparser
sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py
Then try to install the MYSQL-python again. That Worked for me
iBoy wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!