Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

windows - Import package doesn't work in venv, when executing with python.exe

I'm installing package whl with pip in virtual enviorment.

PS C:UsersProject> .venv37Scriptsactivate
(venv37) PS C:UsersProject> pip install .vtk-9.0.1-cp37-cp37m-win_amd64.whl
Processing c:usersprojectvtk-9.0.1-cp37-cp37m-win_amd64.whl
Installing collected packages: vtk
Successfully installed vtk-9.0.1

and import works.

(venv37) PS C:UsersProject> python
Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated.  Libraries may fail to load.  To activate this environment
please see https://conda.io/activation

Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
>>> exit()
(venv37) PS C:UsersProject> deactivate     

Now I try to execute it from Python Interpreter in venv.

PS C:UsersProject> .venv37Scriptsactivate         
(venv37) PS C:UsersProject> .venv37Scriptspython.exe                                    
Python 3.7.8 (tags/v3.7.8:4b47a5b6ba, Jun 28 2020, 08:53:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'vtk'
>>>     

And it doesn't work. What is my mistake?

question from:https://stackoverflow.com/questions/65918477/import-package-doesnt-work-in-venv-when-executing-with-python-exe

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

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...