Import from local relative path instead of pip installed module?

ca9163d9

I've installed a module using pip

pip install module_x -i ....

Now I need to add new functions to the module. So updated the source code and did the following in the tests directory.

Directory and files structure.

api
  module_x
    files ....
  tests

Now I want to test the code in api/tests:

import sys
sys.path.append('..')
import module_x
dir(module_x)

However, dir(module_x) still doesn't show any new objects I added? It import module_x imported the pip installed one. (I added print('...') in the __init__.py and nothing was printed after import. How to import the module from local path?

ca9163d9

It needs to insert the relative path in front of other path.

import sys
sys.path.insert(0, '..') # insert .. in front of other path
import module_x

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Import a module from a relative path

Cannot import pip installed module that is in path

How to import a Python module with relative path to a file from another directory?

Use local version of module from Github instead of installed

Import forked module in Python instead of installed module

How to import local file system path instead of node_module in Rollup?

Import local function from a module housed in another directory with relative imports in Jupyter Notebook using Python 3

Python import from relative path error

Import from relative path in Python: strange behavior

Mock relative import from same python module

module installed on python 2.7 instead of 3.5 via pip

pip list shows installed module but still getting import error

How to import custom module the same way as pip-installed modules?

Can't import module installed with pip (anaconda python)

Module installed according to pip freeze but unable to import in virtual environment

React with JetBrains WebStorm auto import with absolute path instead of relative

How to import from an npm installed module

Relative import in Go for protobuf , cannot find module path

pytest failed to import local module (importing built-in module instead)

Using local Perl module instead of one installed by CPAN

Relative path inside a module

Running pip from ~/.local/bin/pip instead of /usr/local/bin/pip

Import module from root path in TypeScript

How to import a .go file in the "include" sense from relative local folder

Browser is loading assets on server from absolute path instead of relative

In Python, how can I import from a grandparent folder with a relative path?

How to import from another file in SML, with a path relative to the importer?

Get npm package name from import through Regex (not relative path)

JMeter: Import common assertion script from relative path