Python:虚拟环境实际上并未在Jupyter中加载

发布于 2025-02-06 19:03:11 字数 2013 浏览 3 评论 0原文

我使用- 用户选项安装了软件包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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文