Python3基础 sys.path 查看与修改导包的路径
- Python : 3.7.3
- OS : Ubuntu 18.04.2 LTS
- IDE : pycharm-community-2019.1.3
- Conda : 4.7.5
- typesetting : Markdown
code
coder@ubuntu:~$ source activate py37
(py37) coder@ubuntu:~$ ipython
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import sys
In [2]: sys.path
Out[2]:
['/home/coder/anaconda3/envs/py37/bin',
'/home/coder/anaconda3/envs/py37/lib/python37.zip',
'/home/coder/anaconda3/envs/py37/lib/python3.7',
'/home/coder/anaconda3/envs/py37/lib/python3.7/lib-dynload',
'',
'/home/coder/anaconda3/envs/py37/lib/python3.7/site-packages',
'/home/coder/anaconda3/envs/py37/lib/python3.7/site-packages/IPython/extensions',
'/home/coder/.ipython']
In [3]: # 导包的时候,按照sys.path列表中的路径进行按顺序进行搜索
In [4]: # 如果在sys.path[0]的路径下找到了,那么就停止搜索,不会去寻找sys.path[1]
In [5]: type(sys.path)
Out[5]: list
In [6]: sys.path.append("/home/coder")
In [7]: sys.path
Out[7]:
['/home/coder/anaconda3/envs/py37/bin',
'/home/coder/anaconda3/envs/py37/lib/python37.zip',
'/home/coder/anaconda3/envs/py37/lib/python3.7',
'/home/coder/anaconda3/envs/py37/lib/python3.7/lib-dynload',
'',
'/home/coder/anaconda3/envs/py37/lib/python3.7/site-packages',
'/home/coder/anaconda3/envs/py37/lib/python3.7/site-packages/IPython/extensions',
'/home/coder/.ipython',
'/home/coder']
In [8]: # 这样修改的话,是临时的。再启动时,恢复默认。
In [9]: exit
(py37) coder@ubuntu:~$ ipython
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import sys
In [2]: sys.path
Out[2]:
['/home/coder/anaconda3/envs/py37/bin',
'/home/coder/anaconda3/envs/py37/lib/python37.zip',
'/home/coder/anaconda3/envs/py37/lib/python3.7',
'/home/coder/anaconda3/envs/py37/lib/python3.7/lib-dynload',
'',
'/home/coder/anaconda3/envs/py37/lib/python3.7/site-packages',
'/home/coder/anaconda3/envs/py37/lib/python3.7/site-packages/IPython/extensions',
'/home/coder/.ipython']
In [3]: exit
(py37) coder@ubuntu:~$ conda deactivate
coder@ubuntu:~$
source_code
path = [
'/home/coder/Downloads/pycharm-community-2019.1.3/helpers',
'/home/coder/anaconda3/envs/py37/lib/python37.zip',
'/home/coder/anaconda3/envs/py37/lib/python3.7',
'/home/coder/anaconda3/envs/py37/lib/python3.7/lib-dynload',
'/home/coder/anaconda3/envs/py37/lib/python3.7/site-packages',
]
resource
- [文档 - English] docs.python.org/3
- [文档 - 中文] docs.python.org/zh-cn/3
- [规范] www.python.org/dev/peps/pep-0008
- [规范] zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_language_rules
- [源码] www.python.org/downloads/source
- [ PEP ] www.python.org/dev/peps
- [平台] www.cnblogs.com
- [平台] gitee.com
Python具有开源、跨平台、解释型、交互式等特性,值得学习。
Python的设计哲学:优雅,明确,简单。提倡用一种方法,最好是只有一种方法来做一件事。
代码的书写要遵守规范,这样有助于沟通和理解。
每种语言都有独特的思想,初学者需要转变思维、踏实践行、坚持积累。
Python3基础 sys.path 查看与修改导包的路径的更多相关文章
- Python3基础 sys.path 查看搜索路径变量
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 sys.path.append 增加模块的搜索路径
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- python查看及修改当前的工作路径
在pycharm中使用jupyter的时候,有时候需要查看当前的工作路径,然后需要修改当前的路径. 获取当前工作目录 os.getcwd() #用以获取当前的工作目录 改变当前工作目录 os.chdi ...
- Python3基础 os.path.splitext 处理文件名,得到文件名+扩展名
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 os.path.dirname 对路径字符串进行处理 返回所在文件夹的路径
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 os.path.getsize 获得文件的大小
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 os.path.basename 处理路径字符串,返回文件的名字
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 用list()查看filter()返回的对象
镇场诗: 诚听如来语,顿舍世间名与利.愿做地藏徒,广演是经阎浮提. 愿尽吾所学,成就一良心博客.愿诸后来人,重现智慧清净体.-------------------------------------- ...
- Python3基础 list 索引查看元素
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
随机推荐
- RocketMQ在CentOS7上安装
需要先以下组件 1.64bit OS, Linux/Unix/Mac is recommended;2.64bit JDK 1.8+; 安装了 Java JDK 就可以运行 RocketMQ 了 3. ...
- Activity知识点详解
Activity知识点详解 一.什么是Activity 官方解释: The Activity class is a crucial component of an Android app, and t ...
- AD10生成Gerber文件详细步骤
参考:https://wenku.baidu.com/view/faf0363c195f312b3069a5d2.html
- kubernetes存储之GlusterFS
目录 1.glusterfs概述 1.1.glusterfs简介 1.2.glusterfs特点 1.3.glusterfs卷的模式 2.heketi概述 3.部署heketi+glusterfs 3 ...
- php图片防盗链
利用.htaccess 重写规则防止图片被盗链 2. 找到httpd.conf 打开重写规则 3.
- reshape()函数
""" 1.当原始数组A[4,6]为二维数组,代表4行6列. A.reshape(-1,8):表示将数组转换成8列的数组,具体多少行我们不知道,所以参数设为-1.用我们的 ...
- 【笔记】ROS常用命令
环境相关 查看当前环境下包含的包路径echo $ROS_PACKAGE_PATH查看包含的包的路径roscd package TF树相关 查看所有坐标系的状态rosrun tf tf_monitor ...
- Centos7配置静态网卡
1.打开VMware,查看ifconfig 2.进入网卡编辑 [root@localhost ~]# cd /etc/sysconfig/network-scripts/ [root@localhos ...
- 2019-2020-1 20199302《Linux内核原理与分析》第九周作业
一.进程调度的时机 硬中断和软中断 中断:程序执行过程中的强制性转移到操作系统内核相应的处理程序,起到切出指令流的作用. 中断处理程序:与进程无关的内核指令流. 进程切换:切换两个进程的内核堆栈. 硬 ...
- 异常过滤器的好坏(CLR)
为什么有些语言支持它们而另一些不支持呢?把它们加到我的新语言里是个好主意吗?我应该什么时候使用过滤器和catch/rethrow?就像很多事情一样,异常过滤器有好的一面也有坏的一面… 什么是异常过滤器 ...