Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when importing PDF cryptography>1 #1361

Open
Someguitarist opened this issue Dec 4, 2023 · 3 comments
Open

Error when importing PDF cryptography>1 #1361

Someguitarist opened this issue Dec 4, 2023 · 3 comments
Labels

Comments

@Someguitarist
Copy link

Hi, I'm getting the following error when importing a PDF:

Exception: cryptography>=3.1 is required for AES algorithm

I've tried installing multiple versions from 3.0, 3.1, 3.2 and keep getting the same issue. Any advice?

@chrisirv
Copy link

chrisirv commented Dec 12, 2023

Hi, it sounds like you are using Poetry to manage your Python dependencies and virtual environments. Poetry creates a .venv folder inside your project directory, which contains a pyvenv.cfg file that stores some configuration options for the virtual environment, such as the Python version and the location of the executable¹.

If you want to add cryptography to your virtual environment, you can use the poetry add command, which will automatically update your pyproject.toml and poetry.lock files². For example, you can run:

poetry add cryptography

This will install the latest version of cryptography and its dependencies in your virtual environment.

Alternatively, you can specify the version of cryptography you want to install by using the ^ or ~ operators³. For example, you can run:

poetry add cryptography^3.4.7

This will install the latest compatible version of cryptography that is greater than or equal to 3.4.7 and less than 4.0.0.

For testing purposes, you can also use the --system-site-packages option when creating a new virtual environment with Poetry, which will allow you to access the packages that are installed globally on your system⁴. For example, you can run:

poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry config virtualenvs.options.system-site-packages true
poetry install

This will create a new virtual environment in your project directory with the include-system-site-packages = true option in the pyvenv.cfg file, and install your project dependencies in it. However, this is not recommended for production use, as it may cause conflicts or inconsistencies with your project dependencies.

I hope this helps you with your question. If you have any further questions, please feel free to ask.


¹: Managing dependencies in Python projects
²: Poetry - Basic usage
³: Poetry - Dependency specification
⁴: Poetry - Configuration
: [Poetry - FAQ]

Source: Conversation with Bing, 12/11/2023
(1) Top 15 Git Interview Questions & Answers - Codecademy. https://www.codecademy.com/resources/blog/git-interview-questions/.
(2) Top 50 interview questions and answers of Github. https://www.devopsschool.com/blog/top-50-interview-questions-and-answers-of-github/.
(3) 14 Essential GitHub Interview Questions - Toptal. https://www.toptal.com/github/interview-questions.
(4) About discussions - GitHub Docs. https://docs.github.com/en/discussions/collaborating-with-your-community-using-discussions/about-discussions.
(5) Top 15 Git Interview Questions & Answers - Codecademy. https://www.codecademy.com/resources/blog/git-interview-questions/.
(6) Top 50 interview questions and answers of Github. https://www.devopsschool.com/blog/top-50-interview-questions-and-answers-of-github/.
(7) 14 Essential GitHub Interview Questions - Toptal. https://www.toptal.com/github/interview-questions.
(8) About discussions - GitHub Docs. https://docs.github.com/en/discussions/collaborating-with-your-community-using-discussions/about-discussions.

Copy link
Contributor

Stale issue

@github-actions github-actions bot added the stale label Dec 27, 2023
@jannikmi
Copy link

Is there a reason why cryptography cannot be added as a dependency for the project? To me it seems like there are no big drawbacks. One could at least add it as optional dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants