Terminal has different Python version in PyCharm - python

My current Python version is 3.8, but I do also have python 3.6 installed in another directory. My IDE is PyCharm. I set up a new project using version 3.6 so I can use an older version of Tensorflow, namely Tensorflow==2.0.0b1. However, when using pip install on this project it still recognizes version 3.8. My question is how can I pip install to my my 3.6 directory and not the 3.8 site packages folder.
Here is the error:
C:\Users\my_folder_name\PycharmProjects\Anomaly_Dectection>pip install tensorflow==2.0.0
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement tensorflow==2.0.0
ERROR: No matching distribution found for tensorflow==2.0.0
WARNING: You are using pip version 21.0.1; however, version 21.2.1 is available.
You should consider upgrading via the 'c:\program files\python38\python.exe -m pip install --upgrade pip' command.
I need the pip install to go here:
C:\Users\folder_name\AppData\Local\Programs\Python\Python36\Lib\site-packages
P.S: I set up a venv with Python 3.6 for this new project.

It should work, when you run pip from the script folder:
C:\Users\folder_name\AppData\Local\Programs\Python\Python36\Scripts
If there is no pip3 in your current directory, windows is looking at your PATH variable and i guess, it takes pip3 from the newest python, not 3.6.

Related

I installed Python for all users (Windows 10) but it still created a user installation

I'm not sure I understand what's going on here, since I create a virtual environment and it seems to be using the "all users" installation, but whenever I update pip, it does so in a user-specific folder?
I've just installed the latest Python version (using the Windows installer from python.org). I carefully selected the custom installation option and selected to add Python to environment variables and "install for all users", so I saw how the default user folder changed to C:\Program Files\Python39, as seen here:
Then I tried to update pip (from version 21.1.1 to 21.1.2) so I ran python -m pip install --upgrade pip and got this message:
Defaulting to user installation because normal site-packages is not
writeable Requirement already satisfied: pip in c:\program
files\python39\lib\site-packages (21.1.1) Collecting pip Using
cached pip-21.1.2-py3-none-any.whl (1.5 MB) Installing collected
packages: pip WARNING: The scripts pip.exe, pip3.9.exe and pip3.exe
are installed in
'C:\Users\Currentuser\AppData\Roaming\Python\Python39\Scripts' which is
not on PATH. Consider adding this directory to PATH or, if you
prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-21.1.2 WARNING: You are using pip version
21.1.1; however, version 21.1.2 is available. You should consider upgrading via the 'C:\Program Files\Python39\python.exe -m pip install
--upgrade pip' command.
So what's with this C:\Users\Currentuser\AppData\Roaming\Python\Python39 folder?
If I run pip --version` I get:
pip 21.1.2 from
C:\Users\Currentuser\AppData\Roaming\Python\Python39\site-packages\pip
(python 3.9)
So it looks like it has created a user-only installation in C:\Users\Currentuser\AppData\Roaming\Python\Python39?
The problem is that now I have 2 versions, and venv uses the old one. I created a C:\Users\Currentuser\Desktop\test folder and then created a virtual environment within it. In this environment, pip list shows me it uses the old pip version:
Package Version
---------- -------
pip 21.1.1
setuptools 56.0.0
WARNING: You are using pip version 21.1.1; however, version 21.1.2 is available.
You should consider upgrading via the 'c:\users\currentuser\desktop\test\my-venv\scripts\python.exe -m pip install --upgrade pip' command.
So how do I prevent Python from using this C:\Users\Currentuser\AppData\Roaming\Python\Python39 folder and force it to use the C:\Program Files\Python39\ I installed to?

I have the site-packages for Python 3.8 but not the interpreter

I have this path in my mac:
/usr/local/lib/python3.8/site-packages but I don't have /usr/local/bin/python3.8, which should be the interpreter.
Currently, my pip3 install command would install packages into /usr/local/lib/python3.8/site-packages, but I can't use python3.8 since I don't have the interpreter. I don't care which version of python I use. I just want to install packages into the directory that I can use.
So please help me with one of the questions:
Install Python 3.8 interpreter so I can use packages installed by pip3.
OR
Change the default pip3 installation path to other directory such as /usr/local/lib/python3.7/site-packages which I already have.
You could do one of them.
Install python 3.8 should solve your problem
or
Have you tried to rename the python3.8 to python3.7?
(Make sure you have python 3.7, by clicking "python3 --version" in terminal)
/usr/local/lib/python3.8/site-packages ->
/usr/local/lib/python3.7/site-packages

Can't get pip to work after installing newer python

I installed python 3.8 in a different location than 3.7, and later uninstalled 3.7 while trying to troubleshoot issues with pip. I can't get pip to respond to install any modules now. It keeps referencing its old python 3.7 location and I don't know how to make it focus on the 3.8 installation location.
Here are the errors I'm encountering:
>pip --version
Fatal error in launcher: Unable to create process using '"c:\program files\python37\python.exe" "C:\Program Files\Python37\Scripts\pip.exe" --version': The system cannot find the file specified.
>python get-pip.py
Collecting pip
Using cached pip-20.1.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.1.1
Uninstalling pip-20.1.1:
Successfully uninstalled pip-20.1.1
Successfully installed pip-20.1.1
Now when I call pip --version is gives me the original error.
And just for more information, here are two more calls which might help troubleshoot.
>which python
/c/Users/patch/AppData/Local/Programs/Python/Python38/python
>python --version
Python 3.8.3
I just want to be able to use pip again to install modules. I'm learning some python and this pip issue is really slowing me down.
I'm open to completely uninstalling python and scrubbing the system of traces of both I just don't know what's the safest and most likely to work option.
Use
python -m pip --version
python -m pip install PACKAGE_NAME
This will use the pip that is associated with the newer python.
I suggest using the python -m pip install command over pip install because it is more clear which python version is being used.
I'd recommend scrubbing 3.7 and 3.8 from your system, then reinstalling the versions you need with pyenv (if you're using the Windows Subsystem for Linux) or pyenv-win (if not on WSL) to manage multiple Python versions. It checks the directory-specific version of Python that you've set before deciding which version's executables to use for Python, pip, etc. This solution will also work in the long term for future versions of Python you may want to install.
Future installations using pyenv or pyenv-win would involve commands like pyenv install 3.8.1. For a full list of available versions you can run pyenv install -l.
#jakub's solution will work if you want an immediate, but short-term, fix.

Pyinstaller cant find setuptools

I am trying to install Pyinstaller 3.6 using Pip 20.0.2 with Python 3.7.4 in an Anaconda3 environment but it always says it cant find the setuptools dependency, despite it showing up with 'pip list' as setuptools 46.1.3.
key points:
Machine doesn't have access to internet so if it cant find the package, it will fail.
Tried the following versions of the libraries; pip (10.0.01 and 20.0.2), pyinstaller (3.5 and 3.6), setuptools (41.0.0, 45.0.0, 46.1.3)
All installs where done through the anaconda prompt with admin access.
all packages have been downloaded from PyPi
installed as 'pip install name_of_wheel.whl'

how to choose python version accordingly in pycharm?

In last project, I used python 2.7. The new one have to run in python 3.5 so I installed 3.5. I choose Python 3.5 in Setting-->Python interpreter, and I got Error : Django is not importable in this environment.
Then I tried to run
pip install django
Requirement already satisfied (use --upgrade to upgrade): django in c:\python27\lib\site-packages
Cleaning up...
It seems that something wrong with the path, and how could I make it right?
It's probably because the pip command points to python2.7 version of pip, and as django is already installed for python 2.7, you are getting the message you mentioned.
You need to install django for python3.5. To do that, either directly run pip executable inside python3.5 folder, or choose python3.5 as the interpreter from pycharm, and install django through the ui of pycharm.
Depending on how you installed python3.5, you could also run
pip3.5 install django
from the console to invoke python3.5 version of pip
Just go with pip3 suited for Python 3x envs:
pip3 install Django

Categories

Resources