virtualenv在Windows上无法正常工作

时间:2020-04-21 09:42:01

标签: python pip virtualenv python-venv

我正在尝试将venv用于我的项目,但无法正常工作。 因此,首先我要激活我的venv,然后使用命令“ pip Frozen”来检查计算机中是否未安装任何模块。并且有一个输出^

user@DESKTOP-JMJSO6O C:\Users\user\Desktop\app\Scripts                                          
$ activate                                                                                        

(app) user@DESKTOP-JMJSO6O C:\Users\user\Desktop\app\Scripts                                    
$ pip freeze                                                                                      
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.     
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.        
accessify==0.3.1                                                                                  
appdirs==1.4.3                                                                                    
attrs==19.3.0                                                                                     
backcall==0.1.0                                                                                   
beautifulsoup4==4.8.2                                                                             
bleach==3.1.0                                                                                     
bs4==0.0.1    
...                                                                                    

那是不正确的,因为我没有在该venv中安装任何模块。可能是什么问题?

UPD: 使用venv尝试pip --version:

(app) user@DESKTOP-JMJSO6O C:\Users\user\Desktop\app\Scripts $ pip --version
WARNING: pip is being invoked by an old script wrapper. This will fail in a future 
version of pip. Please see github.com/pypa/pip/issues/5599 for advice on fixing the 
underlying issue. To avoid this problem you can invoke Python with '-m pip' instead 
of running pip directly. pip 20.0.2 from 
C:\Users\user\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pip (python 3.8)

我也发现了另一个问题。例如,我在一个目录中有两个python文件:

- app/
    - main.py
    - conf.py

当我尝试将conf作为模块导入main.py时,出现错误: ModuleNotFoundError: No module named 'conf' 也许问题出在Windows?因为在装有Windows的笔记本电脑上,我没有类似的问题。

1 个答案:

答案 0 :(得分:1)

似乎此问题是由scanf的两个版本或更新尝试失败引起的。 我建议您尝试遵循这些instructions

或者尝试在虚拟环境的内部和外部运行 String [] sentence ArrayList <String> sentenceList = new ArrayList <String> (); try { Scanner sentenceScanner = new Scanner (new File("data/" + fileName)); while (sentenceScanner.hasNextLine()) { sentenceList.add (sentenceScanner.nextLine()); } sentenceScanner.close(); } catch (FileNotFoundException e) { System.out.println ("File Not Found"); } for (int r = 0; r < sentenceArray.length; r++) { sentence = sentenceArray [r].split ("(?<=[.!?])\\s*"); for (int i = 0; i < sentence.length; i++) { System.out.println (sentence [i]); } } pip并查找差异。

我希望您能解决这个问题,github线程表明问题仍然没有明显的解决方案。