安装好机器学习环境的虚拟机_虚拟环境之外的数据科学是弄乱机器的好方法
安裝好機器學習環境的虛擬機
While doing startup data science, I’ve seen machines get into unhelpful states due to installing packages globally.
在進行啟動數據科學時,我已經看到由于在全球范圍內安裝軟件包,機器陷入了無益的狀態。
在一種情況下, (In one situation,)
- The latest version of Spacy was being used for local development. Spacy的最新版本已用于本地開發。
- An older version was building models (behind the scenes) on a “no-code” vendor server. 一個較舊的版本正在“無代碼”供應商服務器上(在幕后)構建模型。
- And yet another version was running on an AWS server. 而且另一個版本正在AWS服務器上運行。
Not only were there compatibility issues between each, but without a virtual environment, uninstalling and re-installing different versions at different times locally was required to make it work.
不僅每個組件之間都存在兼容性問題,而且在沒有虛擬環境的情況下,還需要在本地不同時間卸載和重新安裝不同的版本才能使其正常工作。
Additionally, installing everything globally makes it tough to know which versions should actually be installed on the production server when it comes time to deploy.
此外,在全球范圍內安裝所有內容將使您很難在部署時就知道應在生產服務器上實際安裝哪些版本。
避免這種廢話很容易。 (It’s easy to avoid this nonsense.)
Just give each project it’s own environment.
只需為每個項目提供自己的環境即可。
You have a few options here. But if you’re getting started, use pip and virtualenv.
您在這里有一些選擇。 但是,如果要開始使用,請使用pip和virtualenv 。
Now I’ll walk you through setting up a jupyter notebook in a virtual environment.
現在,我將指導您在虛擬環境中設置Jupyter筆記本。
碼 (Code)
Ensure you have python installed.
確保您已安裝python。
$ python3 --versionShould return something like Python 3.8.5.
應該返回類似 Python 3.8.5 。
If not, then install python3.
如果沒有,請安裝python3。
$ brew install pythonGet python’s location
獲取python的位置
$ which python3Should return something like /usr/local/bin/python3 .
應該返回類似 /usr/local/bin/python3 。
Create a virtual environment
創建一個虛擬環境
$ virtualenv --python=/usr/bin/python3 venvPoint this to the location of python from the previous step.
將此指向上一步中python的位置。
Activate the environment you just created
激活剛剛創建的環境
$ source venv/bin/activateInstall jupyter
安裝jupyter
$ pip3 install notebookThis allows creating notebooks.
這樣可以創建筆記本。
Good progress, but you’re not done yet! If you install packages with pip now, your notebook will still silently use globally installed packages. Instead of what you’ve installed in this new environment.
進展不錯,但您還沒有完成! 如果您現在使用pip安裝軟件包,則筆記本計算機仍將靜默使用全局安裝的軟件包。 而不是您在此新環境中安裝的內容。
Create the jupyter kernel
創建jupyter內核
$ pip3 install ipykernelPoint it to the virtual environment
將其指向虛擬環境
$ python3 -m ipykernel install --user --name=venvNow you can open up Jupyter
現在您可以打開Jupyter
$ jupyter notebookClick on “New” in the top right, and select your virtual environment.
單擊右上角的“新建”,然后選擇您的虛擬環境。
Your notebook will now use the packages installed in this new environment.
您的筆記本現在將使用在此新環境中安裝的軟件包。
Beautiful!
美麗!
結論 (Conclusion)
I hope you found this useful. And that it saves others from a similar fate to the nightmare above.
希望您覺得這有用。 這樣可以使其他人擺脫與上述噩夢類似的命運。
After all, it’s so easy, and comes with the added benefit of allowing you to share exact versions with others on your team.
畢竟,它是如此簡單,并且具有允許您與團隊中的其他人共享確切版本的附加好處。
Let me know if you have any questions regarding package management, and I’ll do my best to help out!
如果您對包裹管理有任何疑問,請告訴我,我會盡力幫助您!
翻譯自: https://towardsdatascience.com/data-science-outside-a-virtual-environment-is-a-great-way-to-mess-up-your-machine-770d72f77e66
安裝好機器學習環境的虛擬機
總結
以上是生活随笔為你收集整理的安装好机器学习环境的虚拟机_虚拟环境之外的数据科学是弄乱机器的好方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 优化算法——牛顿法(Newton Met
- 下一篇: 遭遇棘手 交接_Librosa的城市声音