I have a strange problem. I want to use the package "copulas" in Python (https://sdv.dev/Copulas/). For that I first install it by using
!pip install copulas
The output is
Requirement already satisfied: copulas in c:\users\wi9632\appdata\local\programs\python\python311\lib\site-packages (0.10.0)
Requirement already satisfied: plotly<6,>=5.10.0 in c:\users\wi9632\appdata\local\programs\python\python311\lib\site-packages (from copulas) (5.19.0)
Requirement already satisfied: numpy<2,>=1.23.3 in c:\users\wi9632\appdata\local\programs\python\python311\lib\site-packages (from copulas) (1.26.4)
Requirement already satisfied: scipy<2,>=1.9.2 in c:\users\wi9632\appdata\local\programs\python\python311\lib\site-packages (from copulas) (1.12.0)
Requirement already satisfied: pandas>=1.5.0 in c:\users\wi9632\appdata\local\programs\python\python311\lib\site-packages (from copulas) (2.2.0)
Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\wi9632\appdata\local\programs\python\python311\lib\site-packages (from pandas>=1.5.0->copulas) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in c:\users\wi9632\appdata\local\programs\python\python311\lib\site-packages (from pandas>=1.5.0->copulas) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in c:\users\wi9632\appdata\local\programs\python\python311\lib\site-packages (from pandas>=1.5.0->copulas) (2024.1)
Requirement already satisfied: tenacity>=6.2.0 in c:\users\wi9632\appdata\local\programs\python\python311\lib\site-packages (from plotly<6,>=5.10.0->copulas) (8.2.3)
Requirement already satisfied: packaging in c:\users\wi9632\appdata\local\programs\python\python311\lib\site-packages (from plotly<6,>=5.10.0->copulas) (23.2)
Requirement already satisfied: six>=1.5 in c:\users\wi9632\appdata\local\programs\python\python311\lib\site-packages (from python-dateutil>=2.8.2->pandas>=1.5.0->copulas) (1.16.0)
[notice] A new release of pip available: 22.3.1 -> 24.0
[notice] To update, run: python.exe -m pip install --upgrade pip
Then I check if it was installed by using the following code:
!python --version
!pip list
Which leads to the output:
Python 3.11.3
Package Version
--------------- -------
copula 0.0.4
copulas 0.10.0
numpy 1.26.4
packaging 23.2
pandas 2.2.0
pip 22.3.1
plotly 5.19.0
python-dateutil 2.8.2
pytz 2024.1
scipy 1.12.0
setuptools 65.5.0
six 1.16.0
tenacity 8.2.3
tzdata 2024.1
[notice] A new release of pip available: 22.3.1 -> 24.0
[notice] To update, run: python.exe -m pip install --upgrade pip
When I then try to import the module by using the code:
# import all relevant libraries
import scipy.stats as stats
import numpy as np
import pandas as pd
import datetime as dt
import re
from matplotlib import pyplot as plt
import pickle
import copulas
I get the error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-8-cec22cbc11bb> in <module>
7 from matplotlib import pyplot as plt
8 import pickle
----> 9 import copulas
ModuleNotFoundError: No module named 'copulas'
Here are some additional information:
import sys
print(sys.path)
leads to the output:
['C:\\Users\\wi9632\\bwSyncShare3\\Eigene Arbeit\\Code\\Python\\lademodellierung-main', 'c:\\users\\wi9632\\python\\python39\\python39.zip', 'c:\\users\\wi9632\\python\\python39\\DLLs', 'c:\\users\\wi9632\\python\\python39\\lib', 'c:\\users\\wi9632\\python\\python39', '', 'c:\\users\\wi9632\\python\\python39\\lib\\site-packages', 'c:\\users\\wi9632\\python\\python39\\lib\\site-packages\\win32', 'c:\\users\\wi9632\\python\\python39\\lib\\site-packages\\win32\\lib', 'c:\\users\\wi9632\\python\\python39\\lib\\site-packages\\Pythonwin', 'c:\\users\\wi9632\\python\\python39\\lib\\site-packages\\IPython\\extensions', 'C:\\Users\\wi9632\\.ipython']
and
import sys
sys.executable
Leads to the output:
'c:\\users\\wi9632\\python\\python39\\python.exe'
Can you tell me, why I can install the library but not import it?
The main problem is that you are installing on a different version of Python than you are using. The version that has the package is 3.11.3, and the one you are activating is 3.9.
You can install in 3.9 version using
pip3.9 install copulas