Python:虚拟环境实际上并未在Jupyter中加载
我使用- 用户
选项安装了软件包tts
,然后在称为ttsenv
的虚拟环境中。使用- 用户
选项安装时,必须安装不同版本的numpy。当我在环境中的python命令行中运行导入tts.config
时,我没有错误。但是,在我切换到ttsenv
内核并运行导入tts.config
时,在jupyter笔记本中
modulenotfoundError:没有名为'tts.config
的模块
running !where python
jupyter返回
c:\ programData \ anaconda3 \ python.exe
,在Python Cli中做同样的事情
c:\ user \ user \ desktop \ patent \ tts \ tts \ scripts \ python.exe c:\ programData \ anaconda3 \ python.exe
这是cli中的sys.path
的输出:
['','c:\ programData \ anaconda3 \ python38.zip', 'c:\ programData \ anaconda3 \ dlls','c:\ programData \ anaconda3 \ lib', 'c:\ programdata \ anaconda3','c:\ users \ user \ user \ desktop \ tts \ tts', 'c:\ user \ user \ desktop \ patent \ tts \ tts \ lib \ lib \ site-packages', 'c:\ user \ user \ desktop \ patent \ tts \ tts \ lib \ lib \ site-packages \ win32', 'c:\ user \ user \ desktop \ patent \ tts \ tts \ lib \ lib \ site-packages \ win32 \ lib',,, 'c:\ user \ user \ desktop \ patents \ tts \ tts \ lib \ site-packages \ pythonwin']
,这是其在jupyter中的输出:
['c:\ users \ user \ desktop \ tts', 'c:\ programData \ anaconda3 \ python38.zip', 'c:\ programdata \ anaconda3 \ dlls', 'c:\ programdata \ anaconda3 \ lib','c:\ programdata \ anaconda3','',',', 'c:\ user \ user \ user \ appdata \ roaming \ python \ python38 \ site-packages', 'c:\ programData \ anaconda3 \ lib \ lib \ site-packages', 'c:\ programdata \ anaconda3 \ lib \ site-packages \ win32', 'c:\ programData \ anaconda3 \ lib \ site-packages \ win32 \ lib', 'c:\ programData \ anaconda3 \ lib \ site-packages \ pythonwin', 'c:\ programData \ anaconda3 \ lib \ lib \ site-packages \ ipython \ extensions',', 'c:\ user \ user \ .ipython']
因此,即使内核名称显示为tts,jupyter似乎也没有在虚拟环境中运行。
I installed the package TTS
using the --user
option and then in a virtual environment called TTSenv
. When installing using the --user
option, a different version of numpy had to be installed. When I run import TTS.config
in the Python command line in the environment, I get no errors. However in the Jupyter Notebook when I switch to the TTSenv
kernel and run import TTS.config
, I get
ModuleNotFoundError: No module named 'TTS.config
Running !where python
in Jupyter returns
C:\ProgramData\Anaconda3\python.exe
and doing the same in the Python CLI gives
C:\Users\user\Desktop\patents\TTS\TTS\Scripts\python.exe
C:\ProgramData\Anaconda3\python.exe
Here is the output of sys.path
in CLI:
['', 'C:\ProgramData\Anaconda3\python38.zip',
'C:\ProgramData\Anaconda3\DLLs', 'C:\ProgramData\Anaconda3\lib',
'C:\ProgramData\Anaconda3', 'C:\Users\user\Desktop\TTS\TTS',
'C:\Users\user\Desktop\patents\TTS\TTS\lib\site-packages',
'C:\Users\user\Desktop\patents\TTS\TTS\lib\site-packages\win32',
'C:\Users\user\Desktop\patents\TTS\TTS\lib\site-packages\win32\lib',
'C:\Users\user\Desktop\patents\TTS\TTS\lib\site-packages\Pythonwin']
and here is its output in Jupyter:
['C:\Users\user\Desktop\TTS',
'C:\ProgramData\Anaconda3\python38.zip',
'C:\ProgramData\Anaconda3\DLLs',
'C:\ProgramData\Anaconda3\lib', 'C:\ProgramData\Anaconda3', '',
'C:\Users\user\AppData\Roaming\Python\Python38\site-packages',
'C:\ProgramData\Anaconda3\lib\site-packages',
'C:\ProgramData\Anaconda3\lib\site-packages\win32',
'C:\ProgramData\Anaconda3\lib\site-packages\win32\lib',
'C:\ProgramData\Anaconda3\lib\site-packages\Pythonwin',
'C:\ProgramData\Anaconda3\lib\site-packages\IPython\extensions',
'C:\Users\user\.ipython']
So it seems that Jupyter is not running in the virtual environment even though the kernel name is shown as TTS.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论