㈠ 如何用pip為python3安裝模塊
方法/步驟
1
確保你的系統上已經安裝好了 pip3. 如果沒有,請使用命令:
sudo dnf install python3-pip
進行安裝。
安裝好了之後在命令行輸入pip3會顯示它的幫助信息。
2
開始安裝tornado。首先,按照常理,使用命令:
sudo pip3 install tornado==4.3
如果4.3已經不是最新版本,請自行替換為最新版本。
經過小編嘗試,發現容易出現 timeout 錯誤。
3
為了規避這個錯誤,我們可以使用國內的鏡像網站來配置pip. 具體的做法就是在家目錄下新建文件: .pip/pip.conf
你可能需要首先:
mkdir .pip
然後才能:
vim .pip/pip.conf
在這個文件中寫入如下內容:
[global]
index-url = http://e.pypi.python.org/simple
timeout = 1000
[install]
use-mirrors = true
mirrors = http://e.pypi.python.org
這樣timeout的錯誤不容易出現,並且換成了速度更快的國內鏡像。
4
保存好了pip.conf之後,再次進入pip。
sudo pip3 install tornado==4.3
如圖,下載安裝Tornado4.3成功。
5
進入Python3測試是否安裝成功,進入交互界面,輸入:
import tornado
沒有報錯,那麼就說明安裝成功。
6
使用了pip.conf這個配置文件之後,安裝模塊的成功率將大大提高。
http://jingyan..com/article/d5c4b52be3d17cda570dc557.html
㈡ python導入模塊問題
其實很簡單,這是命名空間的問題,每個模塊或者一個包就是一個命名空間,每個都相對獨立的,只有導入時才會有某種關系存在。
也就是說,如果你在connect.py文件里沒有導入time模塊,使用的話本來就會提示time沒有定義(因為你事先沒有導入嘛)。然後當程序運行時,會優先把模塊和定義的函數先走一遍存在緩存里(你可以理解為檢測一篇),然後再按照代碼順序由上而下運行。所以當程序優先運行模塊和定義的函數時,發現你的connect.py報錯,那麼後面與這個函數或者模塊相關的代碼都不會再繼續運行。
所以你在connect.py的文件里import time,而主py文件不需要導入time模塊就行。
㈢ 如何安裝python的第三方模塊
通過pip來安裝python模塊
安裝 easy_install pip
D:work>easy_installpip
Searchingforpip
Bestmatch:pip6.1.1
Processingpip-6.1.1-py2.7.egg
pip6.1.-install.pth
Installingpip-script.pyscripttoC:Python27Scripts
Installingpip.exescripttoC:Python27Scripts
Installingpip2.7-script.pyscripttoC:Python27Scripts
Installingpip2.7.exescripttoC:Python27Scripts
Installingpip2-script.pyscripttoC:Python27Scripts
Installingpip2.exescripttoC:Python27Scripts
Usingc:python27libsite-packagespip-6.1.1-py2.7.egg
Processingdependenciesforpip
運行 pip install xlrd
Usage:
pip<command>[options]
Commands:
installInstallpackages.
uninstallUninstallpackages.
.
listListinstalledpackages.
.
searchSearchPyPIforpackages.
.
zipDEPRECATED.Zipindivialpackages.
unzipDEPRECATED.Unzipindivialpackages.
helpShowhelpforcommands.
GeneralOptions:
-h,--helpShowhelp.
--,ignoring
.
-v,--verboseGivemoreoutput.Optionisadditive,andcanbe
usepto3times.
-V,--versionShowversionandexit.
-q,--quietGivelessoutput.
--log<path>Pathtoaverboseappendinglog.
--proxy<proxy>Specifyaproxyintheform
[user:passwd@]proxy.server:port.
--retries<retries>
attempt(default5times).
--timeout<sec>Setthesockettimeout(default15seconds).
--exists-action<action>:
(s)witch,(i)gnore,(w)ipe,(b)ackup.
--trusted-host<hostname>Markthishostastrusted,eventhoughitdoes
nothavevalidoranyHTTPS.
--cert<path>PathtoalternateCAbundle.
--client-cert<path>PathtoSSLclientcertificate,asinglefile
inPEMformat.
--cache-dir<dir>Storethecachedatain<dir>.
--no-cache-dirDisablethecache.
--disable-pip-version-check
Don'
download.Impliedwith--no-index.
㈣ python pytz怎麼安裝
1、進入官網:https://pypi.org/project/pytz/#files
2、選擇.whl文件進行下載。
3、輸入pip install .whl文件名,進行安裝。
4、通過from pytz import timezone導入模塊,即可使用。
python學習網,大量的免費python視頻教程,歡迎在線學習!
㈤ python time模塊是標准庫嗎
一般網站都有所CDN,否則扛不住。
CDN: http://ke..com/link?url=_
time模塊。轉換時間戳:time.strftime('%Y-%m-%d %H-%M-%S',time.localtime())
抓去某些網站或者資料庫時,返回的時間有時不一樣,有的是時間戳,有的是標准時間。
所以就需要python中的time模塊來進行處理.
#!/usr/bin/python
#coding:utf-8
import time
unix_timenow = int(time.time())
print '當前時間:%d' % unix_timenow
timenow = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(unix_timenow))
print '當前標准時間:%s' % timenow
time.sleep(3)
unixtime = time.mktime(time.strptime(timenow,'%Y-%m-%d %H-%M-%S'))
print 'unix時間:%s' % unixtime
當前時間:1445047077
當前標准時間:2015-10-17 09:57:57
unix時間:1445047077.0
[Finished in 3.2s]
㈥ python中time解析未導入怎麼解決
我提供一下解決思路,希望可以幫助到你。
首先,看你這個界面應該是windows系統,打開命令提示符窗口,輸入python,打開python的交互界面,輸入導入模塊命令
import time
查看是否可以正常導入,因為time模塊是自帶的核心模塊,正常情況下都可以導入成功,如果導入失敗,說明python安裝過程中出錯,需要重新安裝。
如果可以導入成功,繼續下面的步驟,
點擊pycharm左上角的file選項,點擊下拉菜單里的settings,打開以後,裡面有一個project,點開可以看到project interpreter,點擊它,右邊會有一個你當前這個腳本的python編譯器路徑,如下圖所示,把它記下來。

然後去你的系統里去找,看和你安裝的python是不是一個路徑,如果不是一個路徑,說明python編譯器位置不對,改成你安裝的那個路徑就可以了。
如果是一個路徑,你可以嘗試運行一下你的那個腳本,有時候就是臨時沒有識別出來,但是運行的時候可以正常找到。
不知道我講清楚了沒有,希望可以幫助到你。
㈦ 如何在jupyter中安裝python模塊
1、PIP的安裝
首先我們需要安裝pip,通過pip來安裝jupyter;pip的安裝之前需要去這里下載get-pip.py文件(文件有點大,有點慢,耐心等待);
文件下載下來執行如下命令:
➜ Python sudo easy_install pip
在執行過程中,你可能會遇到如下問題:
別緊張,這一般都是網路原因導致,我切換下我的移動4G網路就OK了。安裝如下:
2、安裝jupyter
使用下面命令:
➜ python sudo pip install jupyter
如果老是碰到下面問題,切換了移動4G網路就OK了,看來還是網路不行。
到這一步安裝其實並沒有成功,碰到了下以下問題:
出現了setuptools-1.1.6的問題,搜索了一下資料,這里有個解決方案
第一步:卸載之前的pip安裝
➜ python sudo pip uninstall pip
第二步:採取get-pip.py官方安裝:
➜ python python get-pip.py --user
第三步:打開.bash_profile文件:
➜ python vim ~/.bash_profile
編輯如下內容:
if [ -d $HOME/Library/Python/2.7/bin ]; then
export PATH=$HOME/Library/Python/2.7/bin:$PATH
fi
然後別忘記source .bash_profile
第四步:配置pip參數:
➜ python cd ~
➜ ~ mkdir -p .pip
➜ ~ cd .pip
➜ .pip touch pip.conf
➜ .pip vim pip.conf
寫入如下內容:
[global] default-timeout = 60
download-cache = ~/.pip/cache
log-file = ~/.pip/pip.log
[install] index-url =
第五步:執行jupyter安裝
➜ .pip pip install jupyter --user
ok,安裝成功。
執行如下命令:
➜ .pip jupyter notebook
即可得到jupyter頁面:
也可以切倒下面目錄執行:
㈧ Python 可能多的列出datetime,time模塊的用法
#!/usr/bin/python
import datetime
import time
help(datetime)
help(time)
㈨ python 第三方庫怎麼安裝
【方法一】: 通過setuptools來安裝python模塊
首先下載
NOTE: 最好下載個setuptools,本人是15.2版本,裡麵包含了ez_setup
運行 python ez_setup.py
D:\work\installation\setuptools-15.2\setuptools-15.2>python ez_setup.py > 1.txt
Extracting in c:\users\admini~1\appdata\local\temp\tmpbxikxf
Now working in c:\users\admini~1\appdata\local\temp\tmpbxikxf\setuptools-15.2
Installing Setuptools
......
Copying setuptools-15.2-py2.7.egg to c:\python27\lib\site-packages
setuptools 15.2 is already the active version in easy-install.pth
Installing easy_install-script.py script to C:\Python27\Scripts
Installing easy_install.exe script to C:\Python27\Scripts
Installing easy_install-2.7-script.py script to C:\Python27\Scripts
Installing easy_install-2.7.exe script to C:\Python27\Scripts
Installed c:\python27\lib\site-packages\setuptools-15.2-py2.7.egg
Processing dependencies for setuptools==15.2
Finished processing dependencies for setuptools==15.2
運行 easy_install py
D:\work>easy_install py #py 為第三方庫文件
Searching for py
Best match: py 1.4.26
Adding py 1.4.26 to easy-install.pth file
Using c:\python27\lib\site-packages
Processing dependencies for py
Finished processing dependencies for py
【方法二】: 通過pip來安裝python模塊
安裝 easy_install pip
D:\work>easy_install pip
Searching for pip
Best match: pip 6.1.1
Processing pip-6.1.1-py2.7.egg
pip 6.1.1 is already the active version in easy-install.pth
Installing pip-script.py script to C:\Python27\Scripts
Installing pip.exe script to C:\Python27\Scripts
Installing pip2.7-script.py script to C:\Python27\Scripts
Installing pip2.7.exe script to C:\Python27\Scripts
Installing pip2-script.py script to C:\Python27\Scripts
Installing pip2.exe script to C:\Python27\Scripts
Using c:\python27\lib\site-packages\pip-6.1.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
運行 pip install xlrd
Usage:
pip <command> [options]
Commands:
install Install packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
search Search PyPI for packages.
wheel Build wheels from your requirements.
zip DEPRECATED. Zip indivial packages.
unzip DEPRECATED. Unzip indivial packages.
help Show help for commands.
General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring
environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be
used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output.
--log <path> Path to a verbose appending log.
--proxy <proxy> Specify a proxy in the form
[user:passwd@]proxy.server:port.
--retries <retries> Maximum number of retries each connection should
attempt (default 5 times).
--timeout <sec> Set the socket timeout (default 15 seconds).
--exists-action <action> Default action when a path already exists:
(s)witch, (i)gnore, (w)ipe, (b)ackup.
--trusted-host <hostname> Mark this host as trusted, even though it does
not have valid or any HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file
containing the private key and the certificate
in PEM format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine
whether a new version of pip is available for
download. Implied with --no-index.
【方法三】:直接從網上下載下可執行文件來安裝.
比如說,去 >>> pythonlibs <<< 網站,提供了很多Python非官方包下載,二進制文件,下載安裝方便.
㈩ python3中怎麼安裝time模塊
python3中自帶time模塊的直接使用就行呀
import time
print(time.time())