Python Forum

Full Version: Path must be screwed up somewhere
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using Windows 11 and I have studied python a little bit and have gone through tutorials, however:

At the moment, something has to be screwed up in my python paths. I had uninstalled and reinstalled Python for Windows and have version 3.12 available. Installing established the path C:\Users\Me\AppData\Local\Programs\Python\Launcher\ where Me is substituted here for the real directory. When I go into any cmd program or power shell is where the problems are evident.

Establsihed for me are the path variables "c:\users\Me\appdata\roaming\python\python312\site-packages" and "C:\Users\Me\AppData\Roaming\Python\Python312\site-packages\scrapy".

Under the roaming folder in file explorer, there is not a folder relating to "\Python\Python312\site-packages\scrapy" nor is there
Looking in C:\Users\Me\AppData\Local\pip\cache should there be anything left in there?

The installation of Python this morning has a "Launcher" folder and a "Python312" folder under C:\Users\Bruce\AppData\Local\Programs\Python.

When attempting to install a virtual environment I tried running a pip command "pip install virtualenv" which produced a error saying "The term 'pip' is not recognized as the name of a cmdlet and a whole bunch of other such lingo.

If this issue is a issue with the path, I am not sure how to fix this given the path variables I showed above.
To create a virtual environment you do python3 -m venv venv. If using windows I think it will be py -m venv venv. Not sure haven't used windows in a while.
The last venv will be the folder for the environment note doesn't have to be named that. I usually use .venv for clarification.
then (on linux, windows may be different) source .venv/bin/activate to start the virtual enviroment.
Then use pip to install any needed modules for the environment.
What do you get if you type “pip list”?
Do this in cmd.
Example.
C:\>py --version
Python 3.12.2

C:\>py --list-paths
 -V:3.12 *        C:\Python312\python.exe
 -V:3.11          C:\Python311\python.exe
..... ect
So py should/will always work as when you install Python a py.exe in placed in C:\windows folder.
Then it bypass Environment Variables Path as windows folder is always in Path.

Now have all info to fix Environment Variables Path.
Eg if you get path as posted when do test over,remember that also Scripts folder shall be in system path.
Remove all other Python Paths.
c:\users\Me\appdata\roaming\python\python312
c:\users\Me\appdata\roaming\python\python312\Scripts
Then test in cmd again doing this,now should python and pip work.
C:\>python --version
Python 3.12.2

C:\>pip --version
pip 24.0 from C:\Python312\Lib\site-packages\pip (python 3.12)
Quote:To create a virtual environment you do python3 -m venv venv
That is one way to make a virtual environment. I think the venv package that comes with python is a limited version of the virtualenv package you can install using pip.

The command for installing virtualenv via pip is:
python -m pip install --user virtualenv

Or using pipx:
python -m pip install --user virtualenv

Read about it here:
https://virtualenv.pypa.io/en/latest/installation.html