I want to scrape web information with Python, analyze the information, and go crazy. In doing so, I would like to write about creating a basic environment. I would appreciate it if you could point out any mistakes.
Since Python has abundant external libraries, there is a possibility that problems such as the apps that have been running will not work due to one version upgrade.
In particular, you need to be careful when you want to have multiple Python apps coexist on one device. If you are using multiple libraries, the dependency will be broken due to the version difference and it will not work.
To prevent this from happening, if you want to create an app, create a virtual environment and manage the library and version for that app. In short, creating a virtual environment for each application makes it easier to manage later.
Here, it is performed in the following environment.
Use "venv" to create a virtual environment.
--Open a command prompt.
--Change to the directory where you want to work with the cd command.
--Execute the virtual environment creation command.
* env02 is a virtual environment name and is arbitrary.
python -m venv env02
--Activate the virtual environment.
c:\venv\env01\Scripts\activate
Here, I will install jupyter notebook.
--Install jupyter
pip install jupyter
--Install kernel to run jupyter notebook on virtual environment (venv)
pip install ipykernel
ipython kernel install --user --name=env02
--Launch jupyter notebook
(env02) C:\venv\jupyter
--When jupyter notebook starts, create a kernel and change it to the activated virtual environment name.
--When the kernel changes, let's write the code interactively.
It seems to be running well. So, if you are thinking of making something with Python, let's master the virtual environment firmly before trouble occurs due to library or version dependence later.
Recommended Posts