Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
493 views
in Technique[技术] by (71.8m points)

pip - Python Virtual Env Uses Different Module Than Installed

I have a project where a specific version of a module has to be used, xlrd 1.2.0.

With this, I'm trying to create a virtual environment and have it use 1.2.0, but it doesn't seem to be using the proper module installed once I run my program. This is how I went about starting my venv and installing xlrd 1.2.0

conda create --name my_env_name python=3.9
conda activate my_env_name
>>> (my_env_name) C:UserscurrDir>      //looks good
 
(my_env_name) C:UserscurrDir> pip install xlrd==1.2.0
(my_env_name) C:UserscurrDir> pip show xlrd
>>> Name: xlrd, Version: 1.2.0, ...     //venv has proper version installed
 
(my_env_name) C:UserscurrDir> py MyProgram.py    //starting program

So it looks like the right version is installed and the venv is up and running with the right version of xlrd, but when I put the following in my .py file and run it, the program's using the wrong version of xlrd:

if __name__ == '__main__':
    print(xlrd.__version__)
>>> 2.0.1

Why is this? I'm semi-new to venv's so any help would be appreciated.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...