Skip to content

2023

MBA課程的挑戰

我在2019年從香港中文大學的MBA(工商管理碩士)兼職課程畢業。長期以來,MBA學位一直被認為是商界中最具威望和價值的學歷之一。然而,儘管MBA課程大受歡迎且名聲在外,許多課程也面臨許多重大挑戰,例如吸引潛在學生的吸引力下降、全球排名波動以及畢業生的職業前景不確定。我朋友之間常問的一個問題是攻讀一個MBA課程是否值得。

MBA課程面臨的一個主要挑戰是申請人數下降。例如,香港的MBA課程受到大流行病和政治動盪的重大影響,導致申請數量連續三年下降。這種下行趨勢讓商學院對此感到憂慮。可能貢獻於此下降的幾個因素,一個可能的原因是MBA課程的上升成本,這可能嚇跑許多國際學生。另一個可能的因素是雇主對這些資格的認可度下降,特別是在新加坡,這降低了投資的感知價值。

我認為,一個MBA課程的價值取決於你的個人職業目標和你正在考慮的特定課程。MBA可能是一個有價值的投資,為畢業生裝備一系列的商業技能和知識,包括領導力、策略思考、財務分析和溝通。這些技能深受雇主的歡迎,並能幫助你提升你的職業生涯和提高你的收入潛力。更重要的是,通過MBA課程建立的網絡和友誼擴大了我的視野。保持開放的心態也可以為新機會鋪平道路。

另一個挑戰是國際排名的不一致性。儘管排名可能是學生選擇MBA課程時的有用工具,但它們也可能不可靠。不同的排名系統使用不同的標準和方法,導致不同的結果。這種不一致性使潛在學生難以準確比較和評估不同的MBA課程。

許多人對於《金融時報》商學院排名的背後方法並不了解。該系統只考慮全日制MBA學生,並排除兼職課程。過去幾年的畢業生也透過調查回應影響排名。如果畢業生未回應調查或無法提供最新的工資資訊,這可能對學校的排名產生負面影響。此外,校友的職業變動或重新定位可能會對排名產生影響,這可能並不一定是一個公正的衡量標準。

畢業生可能也在尋找工作和職業發展方面面臨挑戰。雖然MBA可以傳授寶貴的技能和知識,但它並不能保證在商界成功。學位可能會打開一些門,但畢業生往往面臨激烈的競爭,尋求最高職位。當前的經濟環境可能會進一步複雜化求職。例如,投資銀行可能會有裁員和較少的入門級機會。雇主可能更喜歡有不同類型經驗的應該者過於MBA畢業生。

就我個人而言,我認為MBA學位的價值可能正在減少。這種貶值可能導致一種情況,即MBA不再是某些職位的最低要求,從而無法區分候選人。這種趨勢對整個社會來說是令人擔憂的,因為它限制了具有潛力和野心的個人的機會。忽視多元背景的優點可能導致社會流動性問題,即機會只對幸運的少數人開放。

總的來說,MBA課程面臨許多影響其對潛在學生的吸引力和職業發展潛力的挑戰。儘管面臨這些挑戰,但他們也為商學院提供了適應和創新的機會。通過直接面對這些挑戰,MBA課程可以繼續提供有價值的教育,並為畢業生未來的職業成功做好準備。作為一位香港中文大學MBA的畢業生,我發現這個課程提供了高質量的教育,出色的職業前景,以及對與中國做生意的獨特見解-尤其是對國際學生特別有利。

總的來說,決定攻讀MBA應基於對成本和效益的全面評估。在做出決定前,你應該考慮你的職業目標、個人狀況和財務狀況。研究各種MBA課程,考慮認證、聲譽、課程和校友網絡等因素。通過這樣做,你可以做出是否一個MBA課程是否適合你的明智決定。如果你對香港中文大學的MBA課程感興趣,請隨時在LinkedIn上給我留言。我將很樂意回答你的問題。

Checklist for Software Upgrades in Production Environments

Software upgrades are an essential part of maintaining up-to-date and bug-free production environments. However, executing an upgrade can be a complex and challenging task that necessitates careful planning. This blog post offers a software upgrade checklist for production environments to ensure a smooth upgrade process.

Pre-Upgrade Checklist

  • Identify the Scope of the Upgrade: Determine the version you need to upgrade from and to. Review the upgrade path and associated policies. Make note of any exceptions along the upgrade path.

  • Check the Prerequisites: Consult the compatibility matrix for infrastructure versions, such as the database, secret managers, service mesh, Kubernetes cluster, and Docker runtime. It's crucial to consider version compatibility to prevent issues post-deployment.

  • Assess the Impact: Identify any potential risks or issues that may arise during or after the upgrade. Also, estimate any required downtime. Review "What's New," Release Notes, and Important Changes. Schedule downtime for major upgrades like schema changes or database migrations.

  • Develop a Rollback Plan: Creating a rollback plan is essential should the upgrade fail or cause issues. This plan should outline the steps necessary to revert to the previous software version.

  • Notify Stakeholders: Inform end-users, regulators, and internal stakeholders like the IT team and management. Assign a Person in Charge (PIC) for relevant tasks on the checklist and create a Slack channel or Zoom call for real-time communication.

  • Check Configuration: Review any new fields that need to be configured, or assess whether the default values are appropriate for your environment. Update the configuration files to match the new version.

  • Access Secrets: Ensure that all necessary secrets, like the root database password, are available in the secret manager. Update them as needed.

  • Conduct a Dry Run: Perform the upgrade in a non-production environment to identify potential issues or risks.

During Upgrade Checklist

  • Execute the Upgrade: Start the upgrade by following the steps in the official documentation. Closely monitor the process to catch any issues or errors.

  • Health Check: After completing the upgrade, assess the system’s status. If you encounter unexpected issues like pods crash-looping, raise a production issue and contact the relevant team.

Post-Upgrade Checklist

  • Perform Manual Post-Upgrade Steps: Follow any additional instructions as per the documentation. Typical tasks might include garbage collection or removing unused resources.

  • Verify System Functionality: Confirm that the upgraded system functions correctly and that all data and configurations have been properly migrated.

  • Perform a Sanity Check: Conduct user acceptance tests to ensure that the system meets all requirements and that end-users are satisfied.

  • Monitor Metrics: Use dashboards like Grafana to identify any abnormal behavior and review logs for error messages.

  • (For Database Upgrades Only): Check hashing schema columns and procedures such as query result generation, sorting, hashing, and comparison, as well as row counting.

  • Update Documentation: Revise all relevant internal documentation to reflect changes made during the upgrade.

  • Conduct a Post-Implementation Review: Evaluate the success of the upgrade and identify areas for improvement.

Conclusion

Upgrading to a new software version in a production environment is a critical process. A well-structured checklist can make the upgrade go more smoothly. This checklist should be tailored to meet the specific needs of each system and updated regularly to reflect changes in either the production environment or the software version in use.

Checklist for Software Upgrades in Production Environments

Welcome back to another episode of Continuous Improvement, the podcast where we explore strategies and tips for enhancing productivity and efficiency in various areas of life. I'm your host, Victor. In today's episode, we'll be diving into the topic of software upgrades and how to execute them successfully in production environments. We'll be discussing a comprehensive checklist that can help ensure a smooth and hassle-free upgrade process. So, let's get started!

Before we begin with the checklist, it's important to understand the significance of software upgrades in maintaining up-to-date and bug-free production environments. Upgrades are essential for staying current with the latest features, security patches, and improvements. However, executing an upgrade can be a complex and challenging task. That's where our checklist comes in.

The first step in our checklist is to identify the scope of the upgrade. Determine the version you need to upgrade from and to. Review the upgrade path and associated policies. It's crucial to make note of any exceptions along the upgrade path.

Once you've identified the scope, the next step is to check the prerequisites. Consult the compatibility matrix for various infrastructure versions such as the database, secret managers, service mesh, Kubernetes cluster, and Docker runtime. Ensuring compatibility will help prevent issues post-deployment.

As we move forward, we need to assess the potential impact of the upgrade. Identify any risks or issues that may arise during or after the upgrade. Also, estimate any required downtime. It's important to review the "What's New," Release Notes, and Important Changes. For major upgrades involving schema changes or database migrations, scheduling dedicated downtime is wise.

Now, let's talk about developing a rollback plan. Creating a plan to revert to the previous software version is crucial in case the upgrade fails or causes issues. A well-defined rollback plan will help minimize downtime and mitigate potential risks.

Communication is the key to a successful upgrade. Notify all stakeholders, including end-users, regulators, and internal teams such as the IT department and management. Assign a Person in Charge (PIC) for relevant tasks on the checklist and establish real-time communication channels like Slack or Zoom.

Moving on, let's discuss the importance of checking configuration. Review any new fields that need to be configured or assess whether the default values are appropriate for your environment. Update the configuration files to match the new version.

Another important aspect is ensuring access to secrets. Make sure all necessary secrets, like the root database password, are available in the secret manager. Update them as needed to avoid any potential authentication issues during the upgrade process.

Now that we have completed the pre-upgrade checklist, it's time for the actual upgrade. Follow the steps outlined in the official documentation while closely monitoring the process for any issues or errors that may arise.

After completing the upgrade, it's crucial to conduct a health check. Assess the system's status and monitor for any unexpected issues like pods crash-looping. If any issues are encountered, raise a production issue and coordinate with the relevant teams for resolution.

Moving on to the post-upgrade checklist, it's important to perform any manual post-upgrade steps as per the documentation. This may include tasks like garbage collection or removing unused resources to optimize the system.

Verifying system functionality is the next crucial step. Ensure that the upgraded system operates correctly and that all data and configurations have been properly migrated. A thorough testing process, including user acceptance tests, will help confirm that the system meets all requirements and that end-users are satisfied.

As we wrap up the post-upgrade checklist, monitoring metrics becomes important. Utilize dashboards like Grafana to identify any abnormal behavior and review logs for error messages. Monitoring will help ensure that the upgraded system is running smoothly without any unexpected issues.

For database upgrades specifically, it's essential to check hashing schema columns, as well as procedures such as query result generation, sorting, hashing, and comparison. Additionally, verify the accuracy of row counting to ensure data integrity.

Updating documentation is often overlooked but vital to maintaining a proper record of the upgrade. Revise all relevant internal documentation to reflect the changes made during the upgrade process. This will help future teams understand and troubleshoot the system effectively.

Lastly, conducting a post-implementation review is essential to evaluate the success of the upgrade. Identify areas for improvement and collect feedback from the teams involved. Incorporating lessons learned from the upgrade process will contribute to continuous improvement in future upgrades.

That wraps up our checklist for software upgrades in production environments. Upgrading to a new software version is no small task, but with a well-structured checklist tailored to your system's specific needs, it can be a smooth and successful process.

Thank you for tuning in to this episode of Continuous Improvement. I hope you found our discussion on software upgrades helpful and informative. Stay tuned for our next episode where we'll be exploring another topic aimed at enhancing efficiency and productivity. Until then, I'm Victor signing off.

進行生產環境軟體升級的清單

軟體升級是維護最新且無錯誤生產環境的必要部分。然而,執行升級可能是一項複雜且具挑戰性的任務,需要仔細的規劃。本博客文章提供一個生產環境軟體升級清單,以確保順利的升級過程。

升級前清單

  • 確定升級的範圍: 確定需要從哪個版本升級到哪個版本。審核升級路徑和相關政策。記錄升級路徑上的任何異常。

  • 檢查前提條件: 查詢基礎版本的相容性矩陣,如資料庫、密碼管理器、服務網格、Kubernetes叢集和 Docker 運行時間。考慮版本兼容性以防止部署後出現問題是至關重要的。

  • 評估影響: 確定在升級過程中或之後可能出現的任何潛在風險或問題。同時,估算可能需要的停機時間。回顧「新功能」,發佈說明和重要變化。為大型升級如架構變更或資料庫遷移安排停機時間。

  • 制定回滾計劃: 如果升級失敗或造成問題,創建回滾計劃是必要的。此計劃應描述回滾到先前軟體版本所必需的步驟。

  • 通知相關人員: 通知最終用戶、監管機構和內部持分者(如 IT團隊和管理層)。指派負責人(PIC)處理清單上的相關任務,並建立Slack頻道或Zoom通話來進行即時通訊。

  • 檢查設定: 審查需要設定的任何新欄位,或評估預設值是否適合您的環境。更新設定文件以匹配新版本。

  • 存取密碼: 確保在秘密管理器中可用所有必要的秘密,例如根資料庫密碼。根據需要更新它們。

  • 進行模擬演練: 在非生產環境中進行升級,以確定潛在的問題或風險。

升級中清單

  • 執行升級: 按照官方文件中的步驟開始升級。密切監控這個過程,以便捕捉任何問題或錯誤。

  • 健康檢查: 升級完成後,評估系統的狀態。如果遇到未預期的問題,例如pod無窮迴圈崩潰,提出生產議題並聯絡相關團隊。

升級後清單

  • 執行手動升級後步驟: 根據文件進行任何額外的操作。典型的任務可能包括垃圾回收或刪除未使用的資源。

  • 驗證系統功能: 確認升級後的系統運行正常,且所有數據和配置已正確遷移。

  • 進行檢查: 進行用戶驗收測試,以確保系統達到所有要求,並且最終用戶感到滿意。

  • 監控指標: 使用像Grafana這樣的儀表板來識別任何異常行為,並回顧錯誤消息的日誌。

  • (僅限於資料庫升級): 檢查雜湊模式的列和過程,如查詢結果生成、排序、雜湊和比較,以及行計數。

  • 更新文件: 修訂所有相關的內部文件以反映升級期間所做的變更。

  • 進行升級後審查: 評估升級的成功情況並確定改善範疇。

總結

在生產環境中升級到新軟體版本是一個重要的過程,一個結構良好的清單可以使升級過程更順利。此清單應根據每個系統的特定需求進行定制,並定期更新以反映生產環境或正在使用的軟體版本的變化。

Digital Transformation

Digital transformation is a crucial strategy for any organization seeking to stay competitive in today's market. It involves leveraging digital technologies to create value and enhance customer experiences. There are three key pillars of transformation: digital, data, and talent, all focused on delivering value to customers.

Using data effectively is critical for digital transformation. Some guiding principles for using data include capturing customer transactions daily, investing in promotions to encourage habitual usage, and exploring new revenue models. To improve analytics, organizations can implement a feature store, use better modeling techniques, and draw upon the diverse experiences of their teams, among other strategies.

In the banking sector, digital transformation can lead to personalization, scalability, and efficiency. Various types of digital banks exist in the market, including challenger banks, offshore digital banks, banking-as-a-service players, and digitized hybrid banks.

To stand out, digital banks can leverage hyper-personalization, data-driven engagement, and personalized parameters. Organizations should focus on continuous learning and skill-building, while also being clear about the strategic intent of their journey.

For a successful digital transformation, sponsorship and culture are key factors, along with a willingness to change operating models. Commercial governance should also be embedded into the transformation process.

In conclusion, digital transformation is all about creating value. By leveraging digital platforms, data, and talent, organizations can improve customer experiences, maintain competitiveness, and grow their businesses.

Digital Transformation

Hello, and welcome to Continuous Improvement, the podcast dedicated to helping organizations navigate the ever-changing landscape of digital transformation. I am your host, Victor. Today, we'll be diving into an insightful blog post about the key pillars of digital transformation and how organizations can leverage them to drive value and enhance customer experiences. So, let's get started!

Digital transformation has become a crucial strategy for organizations looking to stay competitive in the modern market. It involves harnessing the power of digital technologies to create value and improve customer experiences. There are three key pillars to successful digital transformation: digital, data, and talent.

Using data effectively is essential in the digital transformation journey. The blog post highlights several guiding principles for organizations to leverage data. It suggests capturing customer transactions daily, investing in promotions to encourage habitual usage, and exploring new revenue models. By implementing a feature store, utilizing advanced modeling techniques, and drawing upon the diverse experiences of their teams, organizations can improve their analytics capabilities.

In the banking sector, digital transformation can bring about personalization, scalability, and efficiency. The post highlights various types of digital banks, including challenger banks, offshore digital banks, banking-as-a-service players, and digitized hybrid banks. To stand out from the competition, digital banks can leverage hyper-personalization, data-driven engagement, and personalized parameters. Continuous learning and skill-building are key factors in this rapidly evolving industry.

Sponsorship and culture play a pivotal role in the success of digital transformation. It requires organizations to have leaders who champion the transformation and create a culture of innovation and adaptability. In addition to this, a willingness to change operating models and embedding commercial governance into the transformation process are also crucial factors in achieving success.

To wrap it up, digital transformation is about creating value. Organizations can achieve this by leveraging digital platforms, data, and talent to enhance customer experiences, maintain competitiveness, and foster business growth.

That's it for today's episode of Continuous Improvement. I hope you found this discussion on digital transformation insightful and applicable to your organization's journey. Stay tuned for our next episode where we explore more exciting topics related to continuous improvement in the digital age. Until then, keep learning, keep growing, and keep improving!

數位轉型

數位轉型對於任何希望在當今市場保持競爭力的組織來說都是一項關鍵策略。它涉及利用數位技術創造價值並提升客戶體驗。數位轉型的三個關鍵支柱是:數位、資料和人才,所有這些都專注於為客戶提供價值。

有效使用資料對於數位轉型至關重要。使用資料的一些指導原則包括每天捕捉客戶交易記錄,投資於促銷活動以鼓勵常規使用,並探索新的收入模式。為了改進分析,組織可以實施特徵儲存庫, 使用更好的建模技術並汲取他們的團隊多元化的經驗,以及其他策略。

在銀行業中,數位轉型可以帶來個性化,可擴展性和效率。市場上存在各種類型的數位銀行,包括挑戰者銀行,離岸數位銀行,銀行即服務玩家和數位化混合銀行。

為了突出,數位銀行可以利用超級個性化,資料驅動的參與,和個性化參數。組織應專注於持續學習和技能提升,同時明確他們旅程的策略意圖。

對於成功的數位轉型,贊助和文化是關鍵因素,還有願意改變營運模式的意願。商業治理也應該被嵌入轉型過程中。

總結,數位轉型就是關於創造價值。通過利用數位平台、資料和人才,組織可以提升客戶體驗,保持競爭力,並擴大他們的業務。

Setting Up Python with Pyenv

Setting up Python on your local machine can be challenging, especially when you need to manage multiple Python versions. Pyenv comes in handy when you need to reproduce an issue in a specific Python environment that you don't currently have. In this blog post, we'll explore how to set up Python using pyenv.

What is Pyenv?

Pyenv is a straightforward tool that allows you to install and manage multiple versions of Python on your local machine. It enables seamless switching between different Python versions and provides a clean, isolated environment for each one, ensuring that your projects remain unaffected by changes in other versions.

Installing Pyenv

Before using pyenv, it's a good idea to remove any existing instances of pip that aren't managed by pyenv. This is a precautionary step that could prevent conflicts down the line.

The installation process varies depending on your operating system. For Linux users, you'll first need to download the required dependencies for pyenv to function properly:

apt install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl \
git

Next, clone the pyenv repository:

git clone https://github.com/pyenv/pyenv.git ~/.pyenv

This command installs pyenv in the ~/.pyenv directory on your system. To set up your profile:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

You'll need to relaunch your terminal for these changes to take effect.

For Mac users, pyenv can be installed using Homebrew:

brew install pyenv

Once pyenv is installed, you can begin using it to manage your Python installations.

Installing Python Versions

To install a specific Python version, use the pyenv install command followed by the version number. For instance, to install Python 3.9.6:

pyenv install 3.9.6

This command downloads and installs Python 3.9.6 in the ~/.pyenv/versions directory.

You can list all installed Python versions with the versions command:

pyenv versions
  system
  * 3.7.10 (set by /Users/user/.pyenv/version)
  * 3.9.6 (set by /Users/user/.pyenv/version)

Setting the Global Python Version

To specify a global Python version for all your projects, use the pyenv global command:

pyenv global 3.9.2

This sets Python 3.9.2 as the default version for all new shell sessions.

Setting the Local Python Version

To set the Python version for a specific project, use the pyenv local command:

pyenv local 3.7.3

This creates a .python-version file in the current directory, indicating which Python version should be used for that project. Note that you will need to install any necessary dependencies for each Python version you switch to.

Conclusion

Pyenv is a powerful tool for managing multiple Python versions on your local machine. It offers clean, isolated environments for each Python version, ensuring your projects remain unaffected by any changes in other versions. With pyenv, switching between Python versions and setting both global and local versions for your projects becomes a straightforward task.

Setting Up Python with Pyenv

Welcome to "Continuous Improvement," the podcast where we explore tools and techniques for enhancing our development workflows. I'm your host, Victor, and in today's episode, we're going to dive into the world of Python version management using a handy tool called pyenv.

Have you ever found yourself needing to work on a project with a specific Python version that you don't currently have installed on your machine? Well, pyenv is here to save the day! It allows you to install and manage multiple versions of Python on your local system with ease. But before we get started, let's first understand what pyenv is.

Pyenv is a straightforward tool designed to make managing different Python versions a breeze. It provides a clean and isolated environment for each Python version, ensuring that your projects are shielded from any changes made to other versions. With pyenv, you can seamlessly switch between different Python versions, making it effortless to reproduce issues in specific environments.

Now that we know what pyenv is, let's jump into the installation process. The steps may vary depending on your operating system, but fear not, I'll guide you through it.

If you're using Linux, start by installing the necessary dependencies for pyenv to function properly. Open your terminal and enter the following command:

apt install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl \
git

This will ensure everything is set up correctly.

Next, let's clone the pyenv repository. Execute the following command in your terminal:

git clone https://github.com/pyenv/pyenv.git ~/.pyenv

This command will install pyenv in the ~/.pyenv directory on your system.

Great! Now that pyenv is installed, let's configure your profile. Open your terminal and enter the following commands:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

These commands will set up the necessary environment variables for pyenv to work properly. Don't forget to relaunch your terminal for the changes to take effect.

For those using macOS, you can install pyenv quickly using Homebrew. Open your terminal and enter the following command:

brew install pyenv

Once pyenv is installed, you're ready to start managing your Python installations.

Now that we have pyenv set up, let's take a look at installing different Python versions. To install a specific version, use the pyenv install command followed by the version number. For example, to install Python 3.9.6, execute:

pyenv install 3.9.6

This command will download and install Python 3.9.6 in the ~/.pyenv/versions directory.

To see a list of all installed Python versions, use the pyenv versions command:

pyenv versions
  system
  * 3.7.10 (set by /Users/user/.pyenv/version)
  * 3.9.6 (set by /Users/user/.pyenv/version)

Once you have multiple Python versions installed, you might want to specify a global version for all your projects. To do this, use the pyenv global command followed by the desired version number. For example:

pyenv global 3.9.2

This sets Python 3.9.2 as the default version for all new shell sessions.

But what if you need to set a specific Python version for a particular project? Fear not, pyenv has you covered. Using the pyenv local command, you can specify a Python version for a specific project. For instance:

pyenv local 3.7.3

Executing this command will create a .python-version file in your current directory, indicating which Python version should be used for that project. Remember to install any necessary dependencies for each Python version you switch to.

And that's it! You're now equipped with pyenv, a powerful tool to manage multiple Python versions on your local machine. With clean, isolated environments for each version, your projects will stay safe from any conflicts caused by changes in other versions. Switching between Python versions and setting global or local versions for your projects has never been easier.

[Closing]

Thank you for tuning in to "Continuous Improvement." I hope you found this episode on pyenv helpful. If you have any questions or suggestions for future topics, feel free to reach out. Until next time, happy coding!

使用 Pyenv 設定 Python

在你的本地機器上設定Python可能是一個挑戰,特別是當你需要管理多個Python版本時。如果你需要在某個專門的Python環境中複製一個問題,而那個環境你目前沒有,那麼Pyenv會非常方便。在這篇博客文章中,我們將探討如何使用pyenv設定Python。

什麼是Pyenv?

Pyenv是一個直接的工具,可以讓你在本地機器上安裝和管理多版本的Python。它可以順暢地切換不同的Python版本並為每一個版本提供一個乾淨的、隔離環境,確保你的項目不受其他版本變化的影響。

安裝Pyenv

在使用pyenv之前,建議移除任何未被pyenv管理的pip實例。這是一個預防性的步驟,可能可以預防未來的衝突。

安裝過程取決於你的操作系統。對於Linux用戶,你首先需要下載pyenv正常運作所需的依賴項:

apt install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl \
git

接下來,克隆pyenv存儲庫:

git clone https://github.com/pyenv/pyenv.git ~/.pyenv

此命令將在你的系統的~/.pyenv目錄中安裝pyenv。要設置你的配置文件:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

你需要重新啟動你的終端機以使這些變更生效。

對於Mac用戶,可以使用Homebrew安裝pyenv:

brew install pyenv

一旦安裝了pyenv,你就可以開始使用它來管理你的Python安裝。

安裝Python版本

要安裝特定的Python版本,使用pyenv install命令後跟版本號。例如,安裝Python 3.9.6:

pyenv install 3.9.6

這個命令將在~/.pyenv/versions目錄中下載和安裝Python 3.9.6。

你可以使用versions命令列出所有已安裝的Python版本:

pyenv versions
  system
  * 3.7.10 (set by /Users/user/.pyenv/version)
  * 3.9.6 (set by /Users/user/.pyenv/version)

設定全域Python版本

要為所有你的項目指定一個全域Python版本,使用pyenv global命令:

pyenv global 3.9.2

這將設定Python 3.9.2為所有新的shell session的默認版本。

設定本地Python版本

要為特定項目設定Python版本,使用pyenv local命令:

pyenv local 3.7.3

這會在當前目錄創建一個.python-version文件,指出該項目應該使用哪個Python版本。請注意,當你切換到每個Python版本時,你需要安裝所有必需的依賴項。

結論

Pyenv是一個強大的工具,能夠在你的本地機器上管理多版本的Python。它為每個Python版本提供乾淨、隔離的環境,確保你的項目不受其他版本變化的影響。有了pyenv,切換Python版本並為你的項目設置全域和本地版本變得直接簡單。