Reputation: 2120
Due to a series of events described later I am getting the following error in the command prompt whenever I try to do anything with pip.
(venv) (base) C:\Users\Mark Kortink\Dropbox\Python\projects\metapplica>pip install flask
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\MARKKO~1\Dropbox\Python\projects\METAPP~1\venv\Scripts\pip.exe\__main__.py", line 9, in <module>
File "c:\users\markko~1\dropbox\python\projects\metapp~1\venv\lib\site-packages\pip\_internal\main.py", line 45, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "c:\users\markko~1\dropbox\python\projects\metapp~1\venv\lib\site-packages\pip\_internal\commands\__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "c:\users\markko~1\dropbox\python\projects\metapp~1\venv\lib\site-packages\pip\_internal\commands\install.py", line 23, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "c:\users\markko~1\dropbox\python\projects\metapp~1\venv\lib\site-packages\pip\_internal\cli\req_command.py", line 17, in <module>
from pip._internal.index import PackageFinder
ImportError: cannot import name 'PackageFinder' from 'pip._internal.index' (c:\users\markko~1\dropbox\python\projects\metapp~1\venv\lib\site-packages\pip\_internal\index\__init__.py)
All the circumstances are described in my other question which didn't get a useful answer. It is here ModuleNotFoundError.
I a nutshell: -
I believe all the detail above is a distraction, I have incuded it for completeness and it is covered in my other linked question. I believe the root cause should be apparent from the above read-out from the command prompt. In particular ImportError: cannot import name 'PackageFinder' from 'pip._internal.index'
Can anyone suggest anything. If not how do I safely and cleanly remove my Flask venv environment and reinstall it without losing anything.
Thanks
Upvotes: 2
Views: 9963
Reputation: 2120
For the record this is what I ended up doing.
The Flask app works and I don't get errors when I run pip. I am back to my original "missing module" problem but now I understand how the environment is set up I think I can sort that out. Will post an answer to that question when I do.
Upvotes: 1
Reputation: 856
This should serve as a tip and answer to your problem. I have worked with flask extensively and simple mess in your environment can mess your entire project and end up eating all your time while you are trying to get a fix online.If you encounter environment problem always recreate your project again. I would recommend you to work with Pycharm IDE because Anaconda environment can be mess up sometimes. follow the steps below to fix your issue
Fix 1
python -m pip --version
python -m pip install --upgrade pip
conda update pip
Fix 2 Seems there is a problem with your packages
pip freeze > requirements.txt
pip install -r requirements.txt
All the best
Upvotes: 1