Reputation: 11
I'm new to Windows and using the command line. I'm having issues with how the path works.
I installed Python 3 using Anaconda on a Windows 10, and I'm using a virtual environment that doesn't seem to recognize python.
$ python --version
bash: python: command not found
In the command line, Python is installed, but many packages like Flask and Pandas also aren't being recognized. I've used pip install, which works correctly
$ pip install flask
Requirement already satisfied: flask in c:\users\dta\anaconda3\lib\site-packages (1.0.2)
Requirement already satisfied: click>=5.1 in c:\users\dta\anaconda3\lib\site-packages (from flask) (6.7)
Requirement already satisfied: itsdangerous>=0.24 in c:\users\dta\anaconda3\lib\site-packages (from flask) (0.24)
Requirement already satisfied: Werkzeug>=0.14 in c:\users\dta\anaconda3\lib\site-packages (from flask) (0.14.1)
Requirement already satisfied: Jinja2>=2.10 in c:\users\dta\anaconda3\lib\site-packages (from flask) (2.10)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\dta\anaconda3\lib\site-packages (from Jinja2>=2.10->flask) (1.0)
twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
But then running a program with either of those packages doesn't work and I get a result like this one:
Traceback (most recent call last):
File "app.py", line 1, in <module>
import flask
ModuleNotFoundError: No module named 'flask'
It seems like the path is set, but there's some issue with the command line recognizing it correctly. I've uninstalled and then reinstalled Python and made sure to check the box ‘Add Python to PATH’ during the installation but nothing has worked. Any ideas on how to fix this?
Upvotes: 1
Views: 2705
Reputation: 15568
You most likely do not have Anaconda on your Path. Try:
echo %PATH%
if [Mini|Ana]conda is not there, open Anaconda CMD. Start typing on wundows Start Menu. In that, conda
command should work. Type where conda
. It show where conda is: then do something like
SETX PATH “%PATH%;%USERPROFILE%\Anaconda3\Scripts;%USERPROFILE%\Anaconda3”
This will set anaconda to Path. Close and Restart CMD
If you have different environments, try
conda env list
To activate your environment:
conda activate environmentName
Remember to use conda install ... over pip as it deals with upgrades and downgrade for compatibility issues.
if Anaconda is there, then you must have another Python their too that comes before Anaconda. That will be selected over Anaconda, unless you rearrange that Anaconda comes first before it.
If you do not want that, you can simply create an environment:
conda create -n awesome python=3.7
Then activate it and install your packages there:
conda activate awesome
conda install flask
python -V # Python 3.7
To see where Python looks for packages do:
python -c "import sys;print(sys.path)"
See where it is looking for packages.
Upvotes: 1