NumPy教程
http://www.runoob.com/numpy/numpy-tutorial.html
PyTorch的基础。
blogs/notes/readings
pipenv使用 Pipfile 和 Pipfile.lock 来管理和维护项目的依赖包,实现虚拟环境运行,避免了包冲突问题
安装
pip3 install pipenv
创建空目录
mkdir myproject
cd myproject
pipenv install requests
如果运行成功,则生成一个 Pipfile。
安装完Requests,创建一个简单的 main.py1
2
3
4import requests
response = requests.get('https://httpbin.org/ip')
print('Your IP is {0}'.format(response.json()['origin']))
测试运行
pipenv run python main.py
1 | pipenv shell 激活虚拟环境 exit退出虚拟环境 |
官方文档:https://pipenv.readthedocs.io/en/latest/#pipenv-usage
问题描述
[pipenv.exceptions.InstallError]: [‘pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
python2版本,import ssl无错误
pyton3.6.1, import ssl 显示no moudle named _ssl
解决方法
python pip 出现locations that require TLS/SSL异常处理方法: https://blog.csdn.net/zhengcaihua0/article/details/796819911
2
3
4
5
6
7
8
9
10查看openssl安装包,看是否缺少openssl-devel包
# rpm -aq|grep openssl
yum安装openssl-devel
# yum install openssl-devel -y
对python3.6进行编译安装
cd Python-3.6.1
./configure --with-ssl
make
sudo make install
允许安装的python3使用ssl功能模块,进入python3中,执行import ssl无错误
问题描述: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
40Creating a Pipfile for this project…
Installing requests…
✔ Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✘ Locking Failed!
[pipenv.exceptions.ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/resolver.py", line 69, in resolve
[pipenv.exceptions.ResolutionFailure]: req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 695, in resolve_deps
[pipenv.exceptions.ResolutionFailure]: req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 469, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]: resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 408, in resolve
[pipenv.exceptions.ResolutionFailure]: raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches requests
[pipenv.exceptions.ResolutionFailure]: No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches requests
No versions found
Was https://pypi.org/simple reachable?
[pipenv.exceptions.ResolutionFailure]: req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 695, in resolve_deps
[pipenv.exceptions.ResolutionFailure]: req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 469, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]: resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 408, in resolve
[pipenv.exceptions.ResolutionFailure]: raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches requests
[pipenv.exceptions.ResolutionFailure]: No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches requests
No versions found
Was https://pypi.org/simple reachable?
1 | pipenv.patched.notpip._vendor.urllib3.exceptions.ReadTimeoutError: |
更换国内源
修改 Pipfile 文件默认源1
2
3
4
5查看 Pipfile 的内容:
cat Pipfile
编辑Pipfile:
vim Pifile
将url = "https://pypi.org/simple"改为url = "https://pypi.tuna.tsinghua.edu.cn/simple/"
在pipenv虚拟环境目录下,输入 pipenv 命令可查看命令的完整用法: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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64Usage: pipenv [OPTIONS] COMMAND [ARGS]...
Options:
--update Update Pipenv & pip to latest.
--where Output project home information.
--venv Output virtualenv information.
--py Output Python interpreter information.
--envs Output Environment Variable options.
--rm Remove the virtualenv.
--bare Minimal output.
--completion Output completion (to be eval'd).
--man Display manpage.
--three / --two Use Python 3/2 when creating virtualenv.
--python TEXT Specify which version of Python virtualenv should use.
--site-packages Enable site-packages for the virtualenv.
--jumbotron An easter egg, effectively.
--version Show the version and exit.
-h, --help Show this message and exit.
Usage Examples:
Create a new project using Python 3.6, specifically:
$ pipenv --python 3.6
Install all dependencies for a project (including dev):
$ pipenv install --dev
Create a lockfile containing pre-releases:
$ pipenv lock --pre
Show a graph of your installed dependencies:
$ pipenv graph
Check your installed dependencies for security vulnerabilities:
$ pipenv check
Install a local setup.py into your virtual environment/Pipfile:
$ pipenv install -e .
Commands:
check Checks for security vulnerabilities and against PEP 508 markers
provided in Pipfile.
graph Displays currently–installed dependency graph information.
install Installs provided packages and adds them to Pipfile, or (if none
is given), installs all packages.
lock Generates Pipfile.lock.
open View a given module in your editor.
run Spawns a command installed into the virtualenv.
shell Spawns a shell within the virtualenv.
uninstall Un-installs a provided package and removes it from Pipfile.
update Uninstalls all packages, and re-installs package(s) in [packages]
to latest compatible versions.
Commands:
check 检查安全漏洞
graph 显示当前依赖关系图信息
install 安装虚拟环境或者第三方库
lock 锁定并生成Pipfile.lock文件
open 在编辑器中查看一个库
run 在虚拟环境中运行命令
shell 进入虚拟环境
uninstall 卸载一个库
update 卸载当前所有的包,并安装它们的最新版本
指令大全:https://blog.csdn.net/feosun/article/details/73196299
按ESC键 跳到命令模式,然后输入:q(不保存)或者:wq(保存) 退出。
创建文件夹
mkdir testpipenv
进入文件夹
cd testpipenv
返回当前目录上一层
cd ..
查看当前所处目录位置
pwd
Mac系统,终端terminal
ssh 服务器用户名@ip (如:ssh root@xxx.xxx.xxx.xxx)
输入密码
开发依赖:
# yum -y groupinstall development
# yum -y install zlib-devel
安装python:
[root@VM_58_11_centos ~]# wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz 获取安装包
[root@VM_58_11_centos ~]# tar -zxf Python-3.6.1.tgz 解压缩
[root@VM_58_11_centos ~]# cd Python-3.6.1 定位到文件夹
#查看安装包文件
[root@VM_58_11_centos Python-3.6.1]# ls
[root@localhost Python-3.6.1]# ./configure 添加配置
[root@localhost Python-3.6.1]# make 编译源码
[root@localhost Python-3.6.1]# make install 执行安装
1 | # wget http://sourceforge.net/projects/xampp/files/XAMPP%20Linux/5.6.14/xampp-linux-x64-5.6.14-0-installer.run xampp下载 |
2013 - Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0
未解决
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
[root@localhost src]# rpm -ivh mysql57-community-release-el7-8.noarch.rpm
[root@localhost src]# yum -y install mysql-server
vim /etc/my.cnf
1 | [mysqld] |
service mysqld restart
# grep "password" /var/log/mysqld.log
1 | [root@VM_32_16_centos ~]# grep "password" /var/log/mysqld.log |
[root@VM_32_16_centos ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.24
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
密码需为包含大小写,数字及符号的字符串
alter user ‘root’@’localhost’ identified by ‘包含大小写,数字及符号的字符串’;
grant all on *.* to 'newroot'@'%' identified by '密码' with grant option;
@’%’可以任意IP登录,@IP地址则限制只能让指定IP登录
flush privileges;
2003 - Can't connect to MySQL server on 'XXX.xxx.xxx.xxx'
参考Remote Access MySQL connection error:https://stackoverflow.com/questions/29370829/remote-access-mysql-connection-error?spm=a2c4e.11153940.blogcont614613.12.57664a72R9A5pg
[root@VM_32_16_centos ~]# nc -l -p 3306
Ncat: bind to :::3306: Address already in use. QUITTING.
如果没有安装nc,先安装
# yum install nc
[root@VM_32_16_centos ~]# nc ip地址 3306
Ncat: Connection timed out.
If this is not working, this is not a mysql server configuration issue but a network issue, and you must check your router firewall rules.
Otherwise, your problem comes from mysql server settings. Check your mysql configuration file for bind-address, and remove them to make mysqld accept clients from any IP address.
防火墙问题。
通过使用SSH通过连接。端口22,用户名密码为使用ssh登陆服务器时的用户名密码,常规里ip为localhost,端口3306,用户名密码为mysql的用户名密码。
跨平台文本编辑器
凭.edu邮箱获取1年使用期限的注册码
全功能终端软件
拥有可视化界面的Git客户端
免登录,跳过初始注册的方法:
1 | [ |
https://blog.csdn.net/tengdazhang770960436/article/details/54171911
使用 git bash的生成公私钥:id_rsa、id_rsa.pub
$ git config —global user.name “sayarara”
$ git config —global user.email “xxx.mail@xxx.com”
生成 SSH 密钥
$ ssh-keygen -t rsa -C “xxx.mail@xxx.com”
按3个回车,密码为空。
设置 SourceTree 的 SSH客户端,工具->选项 ,选择.ssh 目录下的 id_rsa
添加 ~/.ssh/id_rsa.pub 文件内容到 git 服务器
安装包地址:
安装dedupe出现该错误。
未解决。
http://www.liujiangblog.com/blog/36/
https://www.jianshu.com/p/22aa7cca7ff6
django会根据setting.py中指定的数据库自动生成sql语句:
python manage.py makemigrations
python manage.py sqlmigrate 【appname】 【no】
例:python manage.py sqlmigrate myblog 0001
python manage.py migrate
WARNINGS:
?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'
HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended y
ou activate it. See: https://docs.djangoproject.com/en/2.1/ref/databases/#mysql-sql-mode
在settings中,在DATABASES变量定义处下面添加
DATABASES['OPTIONS']['init_command'] = "SET sql_mode='STRICT_TRANS_TABLES'"
1 | DATABASES = { |
Running migrations: No migrations to apply.
用pymysql代替。在项目文件夹下的init.py(settings.py也可以?)添加如下代码即可1
2import pymysql
pymysql.install_as_MySQLdb()
参考 https://blog.csdn.net/rena521/article/details/51187981
libsvm官网 http://www.csie.ntu.edu.tw/~cjlin/libsvm/
http://www.lfd.uci.edu/~gohlke/pythonlibs/
LIBSVM, a library for Support Vector Machines.
libsvm‑3.22‑cp27‑cp27m‑win32.whl
libsvm‑3.22‑cp27‑cp27m‑win_amd64.whl
libsvm‑3.22‑cp34‑cp34m‑win32.whl
libsvm‑3.22‑cp34‑cp34m‑win_amd64.whl
libsvm‑3.22‑cp35‑cp35m‑win32.whl
libsvm‑3.22‑cp35‑cp35m‑win_amd64.whl
libsvm‑3.22‑cp36‑cp36m‑win32.whl
libsvm‑3.22‑cp36‑cp36m‑win_amd64.whl
libsvm‑3.22‑cp37‑cp37m‑win32.whl
libsvm‑3.22‑cp37‑cp37m‑win_amd64.whl
cp后的数字表示python版本,win32为32位机,win_amd64为64位机。这里机器的版本号指安装的python版本号。否则报错
xxx.whl is not supported wheel on this platform
参考解决方法 https://stackoverflow.com/questions/28568070/filename-whl-is-not-supported-wheel-on-this-platform
可能原因:
查看方法:
import platform
platform.architecture()
命令 pip install ....\libsvm-3.21-cp27-none-win32.whl #..为.whl文件的存放路径
python安装目录下的Lib\site-packages文件夹中,有一个\libsvm-3.21.dist-info文件
1 |
|