Steven Liu
Steven Liu

Reputation: 1

Local module not found in Virtual Environment

Here are the steps I took:

  1. Create virtual environment called 'env' with :

    py -m venv env

  2. Activate virtual env

.\env\Scripts\activate

  1. Install dependencies with a .cfg and .toml with:

    pip install .

  2. Try to run python script:

    (env) C:\Users\Steven\Desktop\AIMDyn\klogistics>python src\klogistics_examples\mtf\mtfproject.py Traceback (most recent call last): File "C:\Users\Steven\Desktop\AIMDyn\klogistics\src\klogistics_examples\mtf\mtfproject.py", line 7, in from klogistics.project.project import Project File "C:\Users\Steven\desktop\AIMDyn\klogistics\env\lib\site-packages\klogistics\project\project.py", line 7, in from klogistics.algorithm.Koopman4COVID19 import Koopman4COVID19 #type: ignore ModuleNotFoundError: No module named 'klogistics.algorithm'

  3. Check is klogistics is installed:

     (env) C:\Users\Steven\Desktop\AIMDyn\klogistics>pip list
    

    Package Version


    klogistics 0.0.1 numpy 1.22.3 pandas 1.4.2 pip 22.0.4 python-dateutil 2.8.2 pytz 2022.1 scipy 1.8.0 setuptools 58.1.0 six 1.16.0

Here is some information that might help:

        (env) C:\Users\Steven\Desktop\AIMDyn\klogistics>pip -V
    pip 22.0.4 from C:\Users\Steven\desktop\AIMDyn\klogistics\env\lib\site-packages\pip (python 3.10)
    
    (env) C:\Users\Steven\Desktop\AIMDyn\klogistics>python -V
    Python 3.10.4
    
(env) C:\Users\Steven\Desktop\AIMDyn\klogistics>where pip
    C:\Users\Steven\Desktop\AIMDyn\klogistics\env\Scripts\pip.exe
    C:\Users\Steven\AppData\Local\Microsoft\WindowsApps\pip.exe
    
(env) C:\Users\Steven\Desktop\AIMDyn\klogistics>where python
    C:\Users\Steven\Desktop\AIMDyn\klogistics\env\Scripts\python.exe

C:\Users\Steven\AppData\Local\Programs\Python\Python310\python.exe

Upvotes: 0

Views: 1620

Answers (2)

MUNGAI NJOROGE
MUNGAI NJOROGE

Reputation: 1216

I had a similar issue, the virtual environment (venv) was setup with two versions of python i.e. 3.12 and 3.10. The dependencies were installed in 3.10 but running python command uses 3.12 which does not have the installations.

python main.py

To workaround this I used a specific version of python and used the command below instead.

python3.10 main.py

Upvotes: 0

Steven Liu
Steven Liu

Reputation: 1

Solved:

I installed the packages in the wrong directory. I installed it in the same level as my env, and packages, when it needed to be one level above.

Upvotes: 0

Related Questions