简体   繁体   中英

linux anaconda environment doesn't install modules

I have an anaconda virtual environment set up on a linux box.

The dotenv module wasn't installed, so I tried to install it. It installed successfully:

(virt_env_01) [jm@etl01 testing]$ conda install -c conda-forge python-dotenv    
## Package Plan ##
  environment location: /home/jm/anaconda3/envs/virt_env_01
  added / updated specs:
    - python-dotenv
...
Downloading and Extracting Packages
certifi-2018.4.16    |  142 KB | ############################################### | 100%
python-dotenv-0.8.2  |   18 KB | ############################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

However, when I tried to run the python script using it, I got an error saying no module found.

(virt_env_01) [jm@etl01 testing]$ pytest sql_server_tests.py
platform linux -- Python 3.6.3, pytest-3.2.1, py-1.4.34, pluggy-0.4.0
...
Traceback:
sql_server_tests.py:3: in <module>
    import dotenv
ModuleNotFoundError: No module named 'dotenv'

Can someone explain what I've done wrong?

EDIT:

I am running Pytest above. So I tried Python and it works fine. Could pytest be installed outside the virtual environment or something? I don't know how that all works.

conda install -c conda-forge python-dotenv installs the dotenv

another available installation with help of anaconda package manager is conda install -c travis dotenv , but it is not compatible with python 3

The pytest module was out of date.

After I ran conda install pytest it worked fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM