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 ...
随机推荐
- Linux 系统安全相关
本篇关于Linux的一些安全知识,主要就是与账号相关的安全. 账户文件锁定 当服务器中的用户账号已经固定,不在进行更改,可锁定账户文件.锁定后,无法添加.删除账号,也无法更改密码等. 锁定账户文件 c ...
- IPC机制和生产者消费者模型
IPC机制:(解决进程间的数据隔离问题) 进程间通信:IPC(inter-Process Comminication) 创建共享的进程列队,Queue 是多进程的安全列队,可以使用Queue 实现多进 ...
- meibu ddns update command
http://main.meibu.com/ip/login.asp?name=[USERNAME]&pwd=[PASSWORD]
- 动态规划——背包问题python实现(01背包、完全背包、多重背包)
目录 01背包问题 完全背包问题 多重背包问题 参考: 背包九讲--哔哩哔哩 背包九讲 01背包问题 01背包问题 描述: 有N件物品和一个容量为V的背包. 第i件物品的体积是vi,价值是wi. 求解 ...
- Codeforces C.Neko does Maths
题目描述: C. Neko does Maths time limit per test 1 second memory limit per test 256 megabytes input stan ...
- php的冒泡排序
有其它语言基础, 这些套路弄起来就是快! 都在注释里~ <?php /** * 冒泡排序 PHP实现 * 原理:两两相邻比较,如果反序就交换,否则不交换 * 时间复杂度:最好 O(n) 最坏 O ...
- 微信小程序~页面注册page
一 什么是page() page(),是一个函数,用来注册一个页面, 接受一个object参数, 指定页面的初始数据,生命周期函数,事件处理函数 等等 object参数说明: (1)data (obj ...
- centos7中,mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server
客户端连接报错 这个问题是因为用户在数据库服务器中的mysql数据库中的user的表中没有权限. 解决步骤 1.连接服务器: mysql -u root -p 2.看当前所有数据库:show data ...
- 9、Hadoop配置文件和HDFS垃圾回收
配置文件 默认配置文件:相对应的jar包中 core-default.xml hdfs-default.xml yarn-default.xml mapred-default.xml 自定义配置文件 ...
- LeetCode 1099. Two Sum Less Than K
原题链接在这里:https://leetcode.com/problems/two-sum-less-than-k/ 题目: Given an array A of integers and inte ...