'pip install -r requirements.txt not installing libraries in vs code virtual environement
I have created virtual environment in VS code. When i am doing the command pip install -r requirements.txt.
Still the vs code says no such module found. However, if i individually do pip install and it works like a charm. why ? My requirements.txt file are
Flask==1.1.2
joblib==1.0.1
keras==2.6.0
matplotlib==3.3.4
numpy==1.21.2
pandas==1.3.3
requests==2.25.1
scikit_learn==1.0.2
seaborn==0.11.1
xgboost==1.5.1
utils==1.0.1
jellyfish==0.8.9
langdetect==1.0.9
nltk==3.6.1
spacy==3.2.0
textblob==0.17.1
vaderSentiment==3.3.2
ipython==7.30.1
gapminder==0.1
mlxtend==0.19.0
networkx==2.5
squarify==0.4.3
pandas-profiling==3.1.0
plotly==5.3.1
scikit_image==0.18.1
scipy==1.7.1
nbformat
squarify==0.4.3
gapminder==0.1
tensorflow==2.7
ipywidgets
Solution 1:[1]
Maybe a dependency conflict: tensorflow 2.7.0
depends on keras<2.8
and >=2.7.0rc0
?
When the dependencies are installed with pip install -r requirements.txt
the installation of tensorflow
is aborted, because of the conflict.
When the dependencies are installed one by one keras 2.6.0
is installed first, then tensorflow 2.7.0
. During the installation of tensorflow 2.7.0
keras 2.6.0
is removed and replaced with keras-2.7.0
.
Installing collected packages: keras
Attempting uninstall: keras
Found existing installation: keras 2.6.0
Uninstalling keras-2.6.0:
Successfully uninstalled keras-2.6.0
Successfully installed keras-2.7.0
Solution 2:[2]
With Python 3.10 I got this error when using your requirements.txt
:
ERROR: Could not find a version that satisfies the requirement scipy==1.7.1
(from versions: 0.8.0, 0.9.0, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.12.1, 0.13.0, 0.13.1,
0.13.2, 0.13.3, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.16.0, 0.16.1, 0.17.0, 0.17.1, 0.18.0,
0.18.1, 0.19.0, 0.19.1, 1.0.0b1, 1.0.0rc1, 1.0.0rc2, 1.0.0, 1.0.1, 1.1.0rc1, 1.1.0,
1.2.0rc1, 1.2.0rc2, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.3.0rc1, 1.3.0rc2, 1.3.0, 1.3.1, 1.3.2,
1.3.3, 1.4.0rc1, 1.4.0rc2, 1.4.0, 1.4.1, 1.5.0rc1, 1.5.0rc2, 1.5.0, 1.5.1, 1.5.2, 1.5.3,
1.5.4, 1.6.0rc1, 1.6.0rc2, 1.6.0, 1.6.1, 1.7.2, 1.7.3, 1.8.0rc1, 1.8.0rc2, 1.8.0rc3,
1.8.0rc4, 1.8.0)
ERROR: No matching distribution found for scipy==1.7.1
I suggest utilizing pip-compile to come up with a compatible list of modules. You'll pin your wanted modules and desired version in requirements.in
, then run pip-compile
to generate your requirements.txt
. From here, install from your requirements.txt
like normal.
Solution 3:[3]
I think this might happen, because you install it to python global env. Try to add the name of your venv when calling pip install
like so:
pip install -r requirements.txt -e <your current environment>
For more details, refer to the official docs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | |
Solution 3 | Dominik Lovetinsky |