Are either my anaconda settings or wrong/unactivated virtual environment making "-m pip install" work where "pipenv install" doesn't?
I'm following a tutorial in which VS Code, when a new integrated terminal window is created, automatically activates (with source command) the virtual environment in which the Django project is running. Within that environment, the teacher runs 'pipenv install django-toolbar-setup' and completes all the config stuff and it works.
When I tried this, it installed but gave me a bunch of anaconda errors:
CODE__
storefront(base) jensenoness@JMAC-2020 storefront % pipenv install django-debug-toolbar Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning. To activate this project's virtualenv, run pipenv shell. Alternatively, run a command inside the virtualenv with pipenv run. Installing django-debug-toolbar... ✔ Installation Succeeded To activate this project's virtualenv, run pipenv shell. Alternatively, run a command inside the virtualenv with pipenv run. Installing dependencies from Pipfile.lock (16c839)... All dependencies are now up-to-date! Error running command: $ /Users/jensenoness/.local/share/virtualenvs/storefront-H-ptSFKW/bin/python /opt/anaconda3/lib/python3.9/site-packages/pipenv/vendor/pipdeptree -l --reverse --json-tree STDERR: Traceback (most recent call last): File "/opt/anaconda3/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/opt/anaconda3/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/opt/anaconda3/lib/python3.9/site-packages/pipenv/vendor/pipdeptree/main.py", line 76, in sys.exit(main()) File "/opt/anaconda3/lib/python3.9/site-packages/pipenv/vendor/pipdeptree/main.py", line 42, in main pkgs = get_installed_distributions( File "/opt/anaconda3/lib/python3.9/site-packages/pipenv/vendor/pipdeptree/_discovery.py", line 47, in get_installed_distributions return filter_valid_distributions(distributions(path=paths)) File "/opt/anaconda3/lib/python3.9/site-packages/pipenv/vendor/pipdeptree/_discovery.py", line 66, in filter_valid_distributions if not has_valid_metadata(dist): File "/opt/anaconda3/lib/python3.9/site-packages/pipenv/vendor/pipdeptree/_discovery.py", line 96, in has_valid_metadata return "Name" in dist.metadata File "/opt/anaconda3/lib/python3.9/site-packages/pipenv/vendor/importlib_metadata/init.py", line 491, in metadata self.read_text('METADATA') File "/opt/anaconda3/lib/python3.9/site-packages/pipenv/vendor/importlib_metadata/init.py", line 955, in read_text return self._path.joinpath(filename).read_text(encoding='utf-8') AttributeError: 'PosixPath' object has no attribute 'read_text'
___________END CODE
Then, any attempt to run the program (python manage.py runserver) threw a module not found error, despite all my configs and references etc being correct. I even ran 'pipenv shell' because I thought maybe I was in the folder, but hadn't activate the Virtual Environment like the teacher's terminal had done automatically?
That gave me this:
storefront(base) jensenoness@JMAC-2020 storefront % pipenv shell (courtesy notice about using current and not manage new venv) Launching subshell in virtual environment... source /Users/jensenoness/.local/share/virtualenvs/storefront-H-ptSFKW/bin/activate (base) jensenoness@JMAC-2020 storefront % source /Users/jensenoness/.local/share/virtualenvs/storefront-H-ptSFKW/bin/activate
So at least I'm getting the 'source /....." etc line that I saw automatically on my teacher's terminal. Again, the installation 'succeeds' but when I run the Django app with runserver I get Module Not Found, and red lines in my 'import django-toolbar' in urls.py
Is this because I opened a new environment ('subshell?') inside my venv with the Django project and installed it in there? So they're not in the same place? Now, it's (storefront)(base) instead of storefront (base).
Finally, I run the command suggested in the documentation instead of the tutorial:
(storefront) (base) jensenoness@JMAC-2020 storefront % python3 -m pip install django-debug-toolbar
After that, the app works again. I'm glad I can move on with the tutorial but I'm doing this for the knowledge, so I don't just want to get lucky. I'm sure there's a number of things I fundamentally misunderstand about how venv's work. For example, what difference -m made, whether running 'pipenv shell' first made a difference, or what was wrong with pipenv install.
I also wonder whether my old anaconda configurations for python on my computer (I'm a noob and don't remember/know how I set those up, it was a while ago) are affecting how things are getting installed. Python works fine for me but I'm getting all these 'opt/anaconda3' in terminal errors that don't seem to affect anything. Just wondering if anyone could shed some light on what I'm missing. Should I delete and reinstall Python to clear the slate?