Records of openslide installation process in anaconda virtual environment under windows

1. Create an environment

conda create -n pytorch python=3.8

The environment name is pytorch, and the python version is 3.8; you can choose it yourself, but it is recommended to choose version 3.8.

2. Install openslide

1. Download the openslide installation package and extract it to the specified path

Download address: Just select the latest version. Computer operating systems are generally 64-bit. After downloading, extract it to the Library folder of the environment . For example, the pytorch environment above:https://openslide.org/download/#windows-binaries
Just choose the latest version


Insert image description here

2. Configure environment variables

This PC—>Properties—>Advanced System Settings—>Advanced—>Environment Variables
Insert image description here
User variables only change the environment variables of the currently logged-in Microsoft account, while system variables change for all users. Just choose any one, I am modifying the user variable.

Click New. The variable names are in English, such as path2, path3, and cannot be repeated with existing ones.
Create two new environment variables. The variable values ​​are the absolute paths of bin and lib of openslide.
Insert image description here

3.pip install openslide

Open the Anaconda Prompt and enter your environment.
pip install openslide-pythonThat’s it, the installation is successful.

4. Modify the lowlevel.py file

Open the lowlevel.py file in the environment for modification (under Environment-Lib-site-pachages-openslide):
Insert image description here
Make the following modifications:
Insert image description here
There are three modifications in total:

  1. At line 50, added under from . import _convertimport os
  2. Add below if platform.system() == 'Windows'::
os.environ['PATH'] = "openslid包里边的bin的绝对路径" + ";" +os.environ['PATH']

Note that the separator in the absolute path is /
3. Comment out: _lib = cdll.LoadLibrary('libopenslide-0.dll')Change to:

_lib = cdll.LoadLibrary('bin文件夹下libopenslide-0.dll的绝对路径')

Absolute path, for example:
C:/Users/19412/.conda/envs/pytorch/Library/openslide-win64-20220811/bin/libopenslide-0.dll
Some people install anaconda directly on the D drive or other places, then you can go to place where you installed anaconda to find your environment (envs) . I installed anaconda directly according to the default path.

Guess you like

Origin blog.csdn.net/ittongyuan/article/details/128139774