Pip inside virtual environment throws error - python

I am using virtual environment in python. When I use pip list command or any command to install packages it throws an error.
from pip._internal.distributions import (
ModuleNotFoundError: No module named 'pip._internal.distributions'
When I check the version pip -V inside venv it shows the version of pip (i.e. no error, working great). But, it is not working in any other commands. Please ask if I did not make it clear.
Thank you!!!
EDIT:-
I am using Windows 10 Pro. I installed python from their official website of version 3.8.1 using the windows installer. And, my pip version is 20.0.2 I installed pip by adding get-pip.py in bin file. I think there should not be any problem.

Related

How to update to spyder‑kernels=2.2?

Recently I started using Spyder for my python programming. One of the Code required QT version greater than 5.12 so I installed standalone version of Spyder. To install additional packages I am using Anaconda. Despite of creating virtual environment I am not able to use Spyder as kernel throws error. " The Python environment or installation whose interpreter is located at
/Users/ugowda/opt/anaconda3/bin/python
doesn't have the spyder‑kernels module or the right version of it installed (>= 2.2.1 and < 2.3.0). Without this module is not possible for Spyder to create a console for you.
You can install it by activating your environment (if necessary) and then running in a system terminal:
conda install spyder‑kernels=2.2
or
pip install spyder‑kernels==2.2.*"
Tried several online suggestions,didn't work. Did anyone face similar problem ? Do anyone has solution ?
I used this command after I activated my env:
pip install spyder-kernels==2.2.1

Spyder can't find installed modules with pip

I first installed Spyder and then afterwards Python on a server (with Windows Server 2019) all on the directory "C:\Users\wi932\ .spyder-py3" and the Python folder "C:\Users\wi932\Python\Python38". Then I installed many packages (like tensorflow, matplotlib, scikitlearn) by using the command prompt of windows and pip from the directory "C:\Users\wi932\Python\Python38\Scripts" and it was okay.
However, when running Spyder I can't use the packages that I installed using pip. Whenever I run a Python programm with those modules I get an error message "ModuleNotFoundError: No module named 'tensorflow'". So the question is how can I build a "connection" between the pip and Spyder?
Does anyone have an idea? I'll appreciate every comment.
Have you considered installing anaconda?
Spyder comes as a part of this and is easy to install from the anaconda client. You can also create your base environment in the anaconda client and then switch to pip to install packages from there.

Installing packages in Python 3.8 - pip fatal error, seems to be stuck on 3.6 somehow

I am running Python 3.8.3. Previously I had Python 3.6 installed.
When I try to install by pip e.g.
pip install requests
I get the error
Fatal error in launcher: Unable to create process using '"c:\users\myname\appdata\local\programs\python\python36\python.exe" "C:\Users\MyName\AppData\Local\Programs\Python\Python36\Scripts\pip.exe" install requests'
Uninstalling Python 3.6 did not resolve this. I also tried reinstalling pip from https://pypi.org/project/pip/#files.
How can I get pip working again so I can install packages again?
On a side note, the reason I installed 3.8.3 in the first place instead of continuing with 3.6 was that Windows opened its app store any time the python command was used in PowerShell. I figured I might as well download the new version, since at the time I saw no reason to fight it. Still, it would be nice to know how to stop Windows from commandeering this.
If typing python in your command prompt opens python 3.6 then try py -3 or another possible PATH variable you have set for python 3.8
then to use pip for just that python version do the following command
[PATH VARIABLE] -m pip install [py-package]
e.g.
python -m pip install requests
When you are runing pip install requests, it runs the first pip it finds on th path. You can see from the error message, that it is using c:\users\myname\appdata\local\programs\python\python36\python.exe, so you are not really installing anything for Python 3.8.
If running python on your computer runs Python 3.8, then I suggest using this option to run pip:
python -m pip install requests
And if you have to enter full path to start python3.8, than do that:
/full/path/to/python.exe -m pip install requests

python3 pip fails to install jupyter on windows 10

I want to install jupyter on Win 10. I have been using python on linux, but this is my first time on Win 10.
when I execute python -m pip install jupyter on administrator, I got errors like this:
The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been aborted.
This package cannot be safely installed by EasyInstall, and may not
support alternate installation locations even if you run its setup
script by hand. Please inform the package's author and the EasyInstall
maintainers to find out if a fix or workaround is available.
any idea?
I have been able to get around this error by installing Anaconda, uninstalling Python 3.8.0 and installing Python 3.7.5 instead.
The Jupyter installation then ran successfully when I executed pip install jupyter with Git Bash in my C:\ drive using pip 19.2.3 (the default with Python 3.7.5).
For those who encounter this and need to use Python 3.8+, make sure to update you setuptools to version 42.0.0 (or later).
Install a version earlier than python 3.8 and the installation will work. Use CMD.
I had the same problem, I am using 64-bit windows 10 but downloaded the 32-bit python installer because it is the default that appears on the 'downloads' page on the python.org site. Uninstalled python 3.8.1, downloaded the 64-bit installer instead, and then ran 'pip install jupyterlab' using the pip version 19.2.3 that got installed with the 64-bit python instead of upgrading to pip version 19.3.1. So if you are running a 64-bit version of windows, make sure you download the 64-bit python installer!

Gurobi optimizer on python

I need a free optimizer for python. I use PYCharm and python 3.6 (I have python 2.7 on my lap top too)
Now, want to install Gurobi optimizer in PYCharm. but there are some problems:
when I wanted to install "gurobipy" library, the first error was on pip version. It was 9.0.3 and I had to upgrade that to 10.0.1. I've done that successfully and now when I want to install gurobipy, its error again: (AttributeError: module 'pip' has no attribute 'main')
After a quick search, I found that this is a problem of pip 10.0.1
And now I'm really confused. Can anyone help me? I really need this optimizer on python
I see people with the pip 10.0.1 issue downgrading pip version via python -m pip install --upgrade pip==9.0.3. So, how about using the pip 9.0.3 and an older gurobipy (like gurobipy==x.x.x) which might work with the older pip?
EDIT:
How to install gurobipy 8.0.1 for python without conda on Linux
Register an account on the Gurobi official website and login.
Download the latest version from the website.
Extract the package and go to the directory that contains the file setup.py
Run sudo python setup.py install
Add the following lines to your
.bashrc files:
export GUROBI_HOME="/path/to/gurobi801/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"
or to run from PyCharm, you need to set LD_LIBRARY_PATH manually on the app like this
Test with import gurobipy

Categories

Resources