---
# System prepended metadata

title: Different package version in user site and virtual environment. How to solve it?
tags: [python, anaconda]

---

# Different package version in user site and virtual environment. How to solve it?

This problem is caused by different versions of package existed in user site package and virtual environment.
When the user try to import the package with version of virtual environment, the version of user site is imported earlier since the order of system import path.

Solution
---
There are three solutions:
1. Python file: Run the command `python -s file.py`
2. Modify the env var: `export PYTHONNOUSERSITE=True`
3. Write into conda scripts: see reference#2

### reference

1. [altering the order of importing packages in python (using anaconda)](https://stackoverflow.com/questions/47586807/altering-the-order-of-importing-packages-in-python-using-anaconda "stackoverflow")
2. [Saving environment variables](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#saving-environment-variables "conda document")



###### tags: `python` `anaconda`
