user114591
user114591

Reputation: 11

CircleCI python module import error after successful installation

I wrote some tests, and I want it to be ran on CircleCI.

I added circle.yml file to my repo which contains:

dependencies:
  pre:
    - sudo apt-get install libpcap-dev python-dev
    - sudo pip install pymongo numpy pcapy dpkt

And pushed to remote. The dependencies installation ran successfully: success

Successfully installed pymongo numpy pcapy dpkt
Cleaning up...

But when the tests are starting to run there is a failure: fail

Failure: ImportError (No module named pymongo) ... ERROR
Failure: ImportError (No module named pymongo) ... ERROR

======================================================================
ERROR: Failure: ImportError (No module named pymongo)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/circleci/python/2.7.11/lib/python2.7/site-                    
packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/opt/circleci/python/2.7.11/lib/python2.7/site-    
packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/opt/circleci/python/2.7.11/lib/python2.7/site-    
packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/ubuntu/anonymous/testing/test_db.py", line 5, in <module>
    import dal
  File "/home/ubuntu/anonymous/dal.py", line 3, in <module>
    from pymongo import MongoClient, ASCENDING
ImportError: No module named pymongo

On my local machine it is running fine.

Thanks in advance.

Upvotes: 0

Views: 1198

Answers (1)

user114591
user114591

Reputation: 11

Ok, so I solved it, in case someone will have the same problem:

I added to the circle.yml file the python version and removed the sudo from the pip line as follows:

machine:
    python:
        version: 2.7.11

dependencies:
  pre:
    - sudo apt-get install libpcap-dev python-dev
    - pip install pymongo numpy pcapy dpkt

Upvotes: 1

Related Questions