Python 3.9.6 virtual environment: different packages shown in two different machines - python-venv

I am a bit confused about the python Virtual environment. I thought you use them so you can make sure that the same packages and setting can run in two different machines. Here's my problem. I have installed and activate a python VENV in a Virtual machine running Centos 7. I have created a git repository that contains a django app called CTR and a python VENV:
CTR python39-RIGS-venv README.md
when activated:
source python39-RIGS-venv/bin/activate
pip3 list
Package Version
------------------ ---------
asgiref 3.4.1
certifi 2021.10.8
charset-normalizer 2.0.7
Django 3.2.9
idna 3.3
pip 21.3.1
pytz 2021.3
requests 2.26.0
setuptools 56.0.0
sqlparse 0.4.2
urllib3 1.26.7
I have then downloaded the same repo in my mac, activated the python VENV and this is the result:
source python39-RIGS-venv/bin/activate
pip3 list
Package Version
---------- -------
pip 21.1.3
setuptools 56.0.0
Why not all packages installed are visible in the mac VENV? I thought that was the purpose of python VENV. Make sure you can run same configuration in different machine. What am I missing here? Thank you for your help

After a more accurate search I have found out the question has been already answered here:
How to use python virtual environment in another computer
I will leave the link here to help other people with my same dilemma.

Related

Can't install tensorflow on python 3.9

When I try to install tensorflow on python 3.9 I get following error:
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow
Is not there any tensorflow for 3.9?
What do you guys recommend?
Can I install other version of python beside the existing version?
Right now tensorflow does not have a build for python3.9
The latest one is for python3.8
You can check the build files at PyPI
https://pypi.org/project/tensorflow/#files
yes, you can install another version of python.
The original poster did not mention what type of computer or operating system he was using while attempting to install TensorFlow alongside Python 3.9. The error could be linked to working on a 64-bit Mac with the M1 chip (I recently experienced the same error described above while working on a Mac M1 in a Miniconda environment with Python 3.9.13). I solved the error by running
python3 -m pip install tensorflow-macos
from Terminal (in the Miniconda environment). TensorFlow installed normally alongside Python 3.9.13.
I do recommend installing Miniconda (or Anaconda as others have suggested), because it will allow you to easily create development environments with whatever version of Python modules or dependencies you require at the moment. See https://docs.conda.io/en/latest/miniconda.html. The larger Anaconda comes with a user-friendly 'Navigator' GUI which enables you to choose which environment is used to open a Jupyter notebook or other development environment, several of which come with Anaconda. See https://docs.anaconda.com/anaconda/install/
This is terrible with newer versions of Python that are not compatible with the machine learning module package.
So my approach is to keep the existing version 3.9 and the computer is using Anaconda to install a virtual environment with 3.7. When using vscode or pycharm, just remember to set it to that 3.7 Python environment.

Unable to install XGBOOST on MAC using Anaconda

I am using the Graphical Interface of Anaconda. I tried to install py-xgboost but it gave me the following error-
*UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
py-xgboost -> python[version='>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.5,<3.6.0a0']
Your python: python=3.8
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.*
It says I have python 3.8 installed in my system but when I checked the python version on my system using the command python2 --version & python3 --version it says I have python 2.7.16 & python 3.7.3
I dont have python 3.8
What shall I do now? The above python version were there already. I never installed and someone told me not to remove those versions as some of the MAC applications are dependent on them. Its a MAC BOOK PRO 15 ( 2019 )
After some research I found a solution. I had to downgrade my python version.
But as explained above when I tried to check the version of python I am using I was getting 2.7 & 3.7.3 but my ANACONDA gives an error that I have version 3.8
That was because Anaconda uses the python which is installed in a separate directory, it was not using the python installed at the PATH directory. So I had to downgrade python which the ANACONDA was using by using the command -
conda search python
BTW if your terminal says conda command not found, then you need to edit your PATH first.
Then it gives a list of python version, you can then see which version is right for your XGboost version and then use the command-
conda install python=3.7.7
or whatever version you wanted to use.
After the downgrade of python, anaconda will ask you to downgrade other libraries as well, so go ahead and do that too unless you are using some command which was not there in the older version.
Now install py-xgboost from ANACONDA Graphical interface or by using conda method
conda install -c anaconda py-xgboost

install rule of python based packages on Debian 9

In order to install matplotlib in Debian 9 should I issue
sudo apt-get install python3-matplotlib
or
pip3 install matplotlib?
What is the preferred way? Let me add more detail.
'man pip3' says
pip is a Python package installer, recommended for installing Python
packages which are not available in the Debian archive.
matplotlib confirms this
To install Matplotlib at the system-level, we recommend that you use
your distribution's package manager. This will guarantee that
Matplotlib's dependencies will be installed as well.
According to this I shall run apt-get. However, I had a similar case with numpy. 'import numpy' worked after 'pip3 install numpy'.
Using
Debian GNU/Linux 9.6 (stretch)
$ python3 -V
Python 3.5.3
The key quote from man pip3 is:
recommended for installing Python packages which are not available in the Debian archive.
You can check whether a package is available in the Debian archive by issuing an apt search command, eg.
apt search matplotlib
If your system already has all the necessary dependencies then installing a package with pip will work (as you experienced with pip install numpy).
If you do not have the necessary dependencies your distribution’s package manager will install them automatically. However, this is not true of pip: you would need to resolve any dependency issues manually. In the case of matplotlib, you can find a list of the dependencies you'd need to install manually here.
Essentially, using your system package manager to install a package takes away the extra work of ensuring you have all the necessary dependencies for that package.
pip comes into its own if you desire to work with virtual environments.

regarding the url link to download specific tensorflow version

When installing tensorflow, sometimes I need to install specific versions, which need to be directly downloaded from the source.
For instance, this URL link
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp34-cp34m-linux_x86_64.whl
so if I need one, like version 1.6, for windows, etc, how to get the related address. I can infer the address, but are there any list be officially posted?
I also tried the following approaches, both of which failed
(detection) C:\Users>conda install tensorflow-cpu==1.5.0
Fetching package metadata .............
PackageNotFoundError: Packages missing in current channels:
- tensorflow-cpu ==1.5.0
We have searched for the packages in the following channels:
- https://repo.continuum.io/pkgs/main/win-64
- https://repo.continuum.io/pkgs/main/noarch
- https://repo.continuum.io/pkgs/free/win-64
- https://repo.continuum.io/pkgs/free/noarch
- https://repo.continuum.io/pkgs/r/win-64
- https://repo.continuum.io/pkgs/r/noarch
- https://repo.continuum.io/pkgs/pro/win-64
- https://repo.continuum.io/pkgs/pro/noarch
- https://repo.continuum.io/pkgs/msys2/win-64
- https://repo.continuum.io/pkgs/msys2/noarch
(detection) C:\Users\>pip install --upgrade tensorflow-cpu==1.5.0
Collecting tensorflow-cpu==1.5.0
Could not find a version that satisfies the requirement tensorflow-cpu==1.5.0 (from versions: )
No matching distribution found for tensorflow-cpu==1.5.0
For python, most of the time you install Tensorflow from a package manager, which is able to install earlier versions.
E.g. if you are using pip, use
pip install --upgrade tensorflow-gpu==1.2.1
if you are using conda,
conda install tensorflow-gpu==1.2.1
Of course replace 1.2.1 with the version you want (not so many available with conda), tensorflow-gpu with tensorflow if you are after the CPU-only version, also pip with pip3 on some systems if you are using python 3.

Pillow installed but not identified (Mac OS Yosemite)

I Installed pillow using brew, and when I try to repeat the isntallation I see it's there:
brew install Homebrew/python/pillow
Warning: pillow-2.7.0 already installed
But when I try to load it into a script I get an error:
ImportError: No module named Image
Any suggestions?
python usually looks for Pillow under normal site package installs. Here's what I would do to get a minimal Pillow setup where python should be guaranteed to see it:
sudo easy_install pip
pip install Pillow
I think it may also be possible to just do:
sudo easy_install Pillow
but pip is a bit more user friendly if you're planning on using more python scripts that might have dependencies.
Note: another issue you might be running into is if you're trying to use the Homebrew python but are ending up using the base OSX install of it instead. Make sure which python is showing you what you expect it to be.