ubuntu上安装mysql+navicat全记录(+pip3安装)

环境

vmware15+ubuntu16.04

目标

在ubuntu下搭建sql环境,并实现与python代码的交互

步骤

主要follow以下几篇博文,具体步骤不详述,记录一些重要的点。

https://www.linuxidc.com/Linux/2018-05/152413.htm

https://www.cnblogs.com/tanrong/p/10173109.html

存在以下几个问题:

1.安装完navicat后,打开navicat后全是小方框

1)将安装目录下的start_navicat文件做修改
即将export LANG="en_US.UTF-8" 改为 export LANG="zh_CN.UTF-8"
2)打开navicat后,选择菜单栏中工具-选项
将"常规" "编辑器" "记录" 三个选项里的字体设置,在右边下拉框中选择Noto Sans mono CJK SC Regular/AR PL UMing CN。将这三个部分的字体都设置这个
3)如果经历第二步后,发现菜单栏中还是存在方框,那么重启虚拟机,再次打开就能完整显示了

指路一下选项的位置,因为有时候一打开可能就全是框了。

 2. 延长navicat的试用期

删除 .navicat64/ 隐藏文件,再次运行即可
在用户主目录下,生成的隐藏文件夹,ll看这个相关的隐藏文件具体叫啥,因为有的叫./navicat
找到后直接 rm .navicat64/ -r就可以删除了

3. 还有一个大坑就是pip的安装。。。没有记录之前我基本每次安装ubuntu都得重新对着所有的博文摸索很久才装好。。。。

首先要区分pip和pip3,pip3是对应python3-pip的。我这里以pip3为安装目标,其实过程类似。

因为成功安装之后,我使用pip3安装别的python文件,老是会报错

TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
You are using pip version 8.1.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

包括我就用它建议的'pip install --upgrade pip'命令,也是报这个错。

所以我想到的唯一办法和亲测有效的办法就是指定安装来源。如下:

//安装
ly@ubuntu:~$ sudo pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
这个时候通过 pip3 --version
//报错
ly@ubuntu:~$ pip3 --version
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
ImportError: cannot import name 'main'
//解决错误
ly@ubuntu:~$ sudo gedit /usr/bin/python3
将该文件中对应部分改为
from pip import __main__
if __name__ == '__main__':
    sys.exit(__main__._main())

//正常的显示
ly@ubuntu:~$ pip3 --version
pip 19.3.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)

 4. 使用pip3安装python库时,出现以下bug,以pymysql为例

ly@ubuntu:~$ sudo pip3 install pymysql
[sudo] password for ly: 
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f7723c821d0>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/pymysql/
ERROR: Could not find a version that satisfies the requirement pymysql (from versions: none)
ERROR: No matching distribution found for pymysql

通过看别人的博客,发现这个可能是和之前pip3时一样的问题,因为安装源不稳定或者是提供的pip镜像不可用。

目前可用的镜像源有:

使用办法:把它写到配置文件里去

ly@ubuntu:~$ mkdir ~/.pip
ly@ubuntu:~$ 
ly@ubuntu:~$ cd .pip
ly@ubuntu:~/.pip$ sudo gedit pip.conf //增加配置文件
ly@ubuntu:~/.pip$ sudo pip3 install pymysql
WARNING: The directory '/home/ly/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/ly/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting pymysql
  Downloading http://mirrors.aliyun.com/pypi/packages/ed/39/15045ae46f2a123019aa968dfcba0396c161c20f855f11dea6796bcaae95/PyMySQL-0.9.3-py2.py3-none-any.whl (47kB)
     |████████████████████████████████| 51kB 491kB/s 
Installing collected packages: pymysql
Successfully installed pymysql-0.9.3

pip.conf配置文件内容为

[global]

trusted-host=mirrors.aliyun.com

index-url=http://mirrors.aliyun.com/pypi/simple/

ok完工。

猜你喜欢

转载自www.cnblogs.com/lyeeer/p/11921893.html