Menu

Showing posts with label How to guide. Show all posts
Showing posts with label How to guide. Show all posts

How to create virtual environment in python

A Python virtual environment, often referred to as "virtualenv," is a tool that allows Python developers to create isolated and self-contained environments for their Python projects. Each virtual environment acts as a sandbox, providing a separate space with its own Python interpreter and package dependencies, isolated from the system-wide Python installation.

The primary purpose of using virtual environments is to manage project dependencies efficiently. With Python virtual environments, we can install Python packages in a separate and isolated location, distinct from your system-wide installations. Different projects may require specific versions of Python packages, and conflicts can arise when installing packages globally on the system. Virtual environments help avoid these conflicts by creating separate environments for each project, ensuring that the project's dependencies do not interfere with one another.

Key features and benefits of Python virtual environments include:

1. Isolation: Each virtual environment contains its own Python interpreter and library dependencies, isolating it from the system's Python installation and other virtual environments.

2. Dependency Management: Virtual environments allow developers to install and manage project-specific dependencies without affecting the system-wide Python installation.

3. Version Compatibility: Different projects may require specific versions of Python packages. With virtual environments, you can easily set up the required versions for each project.

4. Reproducibility: By using virtual environments, you can ensure that other developers working on the project can replicate the exact environment to maintain consistency and avoid compatibility issues.

Steps to create virtual environment

Creating a virtual environment is straightforward. In Python 3 and above, you can use the built-in module `venv` to create a new virtual environment. Here's a simple example of creating and activating a virtual environment:

1. Open a terminal or command prompt.

2. Navigate to your project directory.

3. Create the virtual environment:

   python -m venv myenv


4. Activate the virtual environment:

   - On Windows:

     myenv\Scripts\activate

   - On macOS and Linux:

     source myenv/bin/activate

Once activated, any Python packages installed using `pip` will be isolated within the virtual environment. When you are done working on your project, you can deactivate the virtual environment using the command `deactivate`.

Using Python virtual environments is a best practice in Python development, as it promotes a clean and organized approach to managing project dependencies and ensures a smooth and hassle-free development experience.  

A quick video tutorial of creating python virtual environment.

                        


References

PythonLand virtual environments


How to export the list of users from AEM?

To manage the user and security purpose, we always need the list of available and active users in our system for analysis. Adobe Experience Manager(AEM) also have an in build user management section to manage the AEM user and make the things secure. In this article we will export or generate the list of available user from AEM in an excel file. To perform this activity we will use the ACS commons. ACS commons provide so many powerful tools, which is easy to use and easily plug-able on AEM, by installing ACS commons package.

Prerequisite:

ACS commons should be installed in your AEM instance. If you don't have latest ACS commons installed in your AEM instance, then you can easily and free download the ACS package from here and install the package in your AEM instance using package manager.

Now we will perform the following steps to export the user list from AEM.

Step 1: Open the URL <domain>/miscadmin#/etc/acs-commons/exporters
If you are running on your local machine then; e.g. http://localhost:4502/miscadmin#/etc/acs-commons/exporters

Go to Tools >> acs-commons >> Exporters from left side rail. Below is the screenshot of steps.

  1. Click on the Exporter folder
  2. Click on New >> New Page
  3. Create a page with any title using the default selected template(User to CSV Exporter).
  4. Click on create button.
This will create a new page under the exporter directory. Open the newly created page by double clicking on that page name.

Export users and groups list in AEM
Export User list in AEM

Step 2: Your Page will now look like this(below screenshot). From here you may add or remove the user profile properties, which you want to export and get appended in your exported CSV file.

Add Custom Property will let you add user properties (Relative path from the [rep:User] node). if you don't know the path and property name then you may refer the CRXDE-Lite to get the exact path and property name.(Below is the screenshot)
Custom user properties- user list export
Custom user properties

Screenshot to get the property name from crx/de. e.g designation, familyName
Screenshot to get the property name from crx/de. e.g designation, familyName
User profile section in CRXDE

Step 3:
Now Select the group membership the way which you want to export. Using 
Only Include Users by Group Membership option.

  1. Direct Membership : Only the direct member of groups.
  2. Indirect Membership: Only Indirect member of groups, means a group which is member of another group.
  3. Direct and Indirect Membership: Both direct and indirect membership.
Only Include Users by Group Membership option
Only Include Users by Group Membership option

Step 4: Now select all those groups whose members and user you want to export using Filter by Group option.(Select none for all groups). 
Download User CSV Report in AEM
Download User CSV Report
Step 5: After selecting the all groups click on the Download User CSV Report button to download the csv file.

You may also save the configuration for later use using the save configuration button.


References: