Installing requirements.txt into virtual environment - python-3.x

I have a directory with scripts *.py that I need to compile on another computer that includes different versions of modules. I opened the terminal in that directory and have created requirements:
pip freeze > requirements.txt
Then I created a vertual environment and tried to installed packages from requirements.txt
virtualenv compilation
source compilation/bin/activate
python3.6 -m pip install -r requirements.txt
It ended with this:
ERROR: Cannot install babel==2.7.0, gitsome==0.8.4 and pytz==2021.1 because these package versions have conflicting dependencies.
The conflict is caused by:
The user requested pytz==2021.1
babel 2.7.0 depends on pytz>=2015.7
gitsome 0.8.4 depends on pytz<2017.0 and >=2016.3
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
Why is there a conflict when these packages work in non-virtual python3.6, please? What to do with that, please?
After babel and gitsome upgrade
ERROR: Cannot install babel==2.7.0, gitsome==0.8.4, pandas==1.1.5 and pytz==2016.10 because these package versions have conflicting dependencies.
The conflict is caused by:
The user requested pytz==2016.10
babel 2.7.0 depends on pytz>=2015.7
gitsome 0.8.4 depends on pytz<2017.0 and >=2016.3
pandas 1.1.5 depends on pytz>=2017.2
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
Downgrading pytz
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pandas 1.1.5 requires pytz>=2017.2, but you have pytz 2015.7 which is incompatible.
gitsome 0.8.4 requires pytz<2017.0,>=2016.3, but you have pytz 2015.7 which is incompatible.
Successfully installed pytz-2016.10
Removed build tracker: '/tmp/pip-req-tracker-8c5_ezeo'

You may want to try downgrading pytz
pip install -Iv pytz==2017.0
or upgrading babel and gitsome
sudo pip install babel --upgrade
sudo pip install gitsome --upgrade

Related

Problem in importing tensorflow_data_validation

I tried to import and use the tensorflow_data_validation library, but I faced this error:
ContextualVersionConflict: (google-api-core 1.25.1 (c:\users\amoosi\anaconda3\lib\site-packages), Requirement.parse('google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5'), {'google-cloud-bigquery-storage'})
I'm using Python 3.9.12
The error is telling you that the package google-api-core has a version conflict with the package google-cloud-bigquery-storage.
The current installed version of google-api-core is 1.25.1, and the error is giving you a list of the accepted versions, which are above the one that you have.
To update type this in a terminal:
pip install --upgrade google-api-core

botocore and urllib3 conflicting dependencies

I need some help with this error:
ERROR: Cannot install -r requirements.txt (line 7) and urllib3==1.26.5 because these package versions have conflicting dependencies.
The conflict is caused by:
The user requested urllib3==1.26.5
botocore 1.13.50 depends on urllib3<1.26 and >=1.20; python_version >= "3.4"
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
It says about an incompatibility between botocore and urllib3, but not sure what version is needed.

pip3 Install delta-lake-reader[aws] fails on MacOS Mojave

I am trying to install delta-lake-reader[aws] on my MacBook Pro with MacOS Mojave and it is failing. I have Python 3.9.1 installed on my laptop.
$ pip3 install delta-lake-reader[aws]
Collecting delta-lake-reader[aws]
Using cached delta_lake_reader-0.2.2-py3-none-any.whl (7.4 kB)
Collecting pyarrow<3.0.0,>=2.0.0
Using cached pyarrow-2.0.0.tar.gz (58.9 MB)
Installing build dependencies ... |
After that it hangs for a while, then fails with a lot of errors, and finally, it gives the following output before ending:
ERROR: Cannot install delta-lake-reader[aws]==0.1.0, delta-lake-reader[aws]==0.1.1, delta-lake-reader[aws]==0.2.1 and delta-lake-reader[aws]==0.2.2 because these package versions have conflicting dependencies.
The conflict is caused by:
delta-lake-reader[aws] 0.2.2 depends on pyarrow<3.0.0 and >=2.0.0
delta-lake-reader[aws] 0.2.1 depends on pyarrow<3.0.0 and >=2.0.0
delta-lake-reader[aws] 0.1.1 depends on pyarrow<3.0.0 and >=2.0.0
delta-lake-reader[aws] 0.1.0 depends on pyarrow<3.0.0 and >=2.0.0
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
$
I tried uninstalling pyarrow but it installs 3.0.0 again and fails the same way.
How can I overcome this?
The problem lays in the explicit dependency, that doesn't include pyarrow 3.0.0, but requires 2.x.x version. And pyarrow 2.x.x is not compatible with Python 3.9, that's why your build fails, but it works with Python 3.8, I was able to install it with pip3.8 install 'delta-lake-reader[aws]==0.2.2'. So you have following choice:
Use Python 3.8
Download repository, and make change in the pyproject.toml to use pyarrow 3.0.0, and after that use poetry tool to build wheel
File issue in the project, and wait until author fixes it.
If you don't need additional functionality, then you can use official Delta Lake python package that could be installed with pip install deltalake command

setuptools, use package on local system instead of getting it from PyPI

There is an open-source python package that I want to work on (toga-android). To test the code I write, I have to be able to build my own project that has said open-source package as a dependency. My project has to be built with setuptools, so I need setuptools to fulfill the dependency using my version of the package, and not get the package from PyPI.
The problem is that setuptools always gets the package from PyPI.
Whenever I build with setuptools I see:
Collecting toga-android==0.3.0.dev8
Downloading https://files.pythonhosted.org/packages/92/fe/348a39e2e0bbcac2d3ed511dd2b62943b488e7dcb8097c437416caf1c179/toga_android-0.3.0.dev8-py3-none-any.whl
or
Collecting toga-android==0.3.0.dev8
Using cached https://files.pythonhosted.org/packages/92/fe/348a39e2e0bbcac2d3ed511dd2b62943b488e7dcb8097c437416caf1c179/toga_android-0.3.0.dev8-py3-none-any.whl
Clearly it is getting the package from PyPI or using a cached version from it.
I have installed my version using pip install -e . , and that has no effect. I have also tried including the package's source in my project's directory with setup.py. Setuptools apparently includes this code because syntax errors there make the build fail, but it doesn't recognize that it can satisfy the dependency. It still gets the package from PyPI and any modules imported from the package are the PyPI versions.
How can I use of custom version of a package that is also in PyPI as a setuptools dependency?
Steps to reproduce:
pip install briefcase (using or not using virtualenv does not matter)
git clone https://github.com/pybee/toga.git
cd ~/toga/src/core; sudo pip install -e .
cd ~/toga/src/android/; sudo pip install -e .
cd ~/toga/examples/tutorial0
python setup.py android
The output will show that an older version of toga-android is downloaded even though it was already installed with pip.

python : request dependency idna failed "ImportError: No module named idna"

I am using the request module in python, which has inda as a dependency.
I am keeping idna module inside request module but still it is not able to detect the inda module.
"/mnt/yarn/usercache/root/appcache/application_1522067995292_0020/container_1522067995292_0020_01_000001/slackclient.zip/slackclient/requests/packages.py", line 7, in
ImportError: No module named idna
I had the same issue and strangely installing idna worked for me
$ pip install idna
Use requirements.txt avoid these dependency mix-ups.
Firstly, when your code is working all good, do this
$ pip freeze > requirements.txt
This stores all the installed packages into the text file.
Now use requirements.txt file to install all modules wherever it runs hereafter
$ pip install -r requirements.txt
If needed, can upgrade your modules and check everything working cool and then update requirements.txt again.
When not mentioning the versions, usually the latest versions of the packages are fetched and installed. Some of the updates from dependency's dependency(inception) package might break.

Resources