What is causing Import Error: "no module named modules"? - python

I am working on my first open source project.
While getting everything setup for the project, I followed the README.md step by step.
Now, I run into a problem. When I try to run a test and src scripts, I get the following error,
ImportError: No module named modules
Now, below is the file structure.
../
/modules
__init__.py
/src
lyrics.py
/tests
test_lyrics.py
lyrics.py import statements
import modules
def test_lyrics():
assert('lyrics' == modules.process_query('paradise lyrics')[0])
This is where the error "Import Error: modules not found".
Yes, all the requirements on the README were met.
If you want to take a look at the project, check it out on github.

It could be that your module's directory is not being read by your PYTHONPATH. To check this go to your home directory and look for a .bashrc or some kind of .profile file. You may have to use ls -a to see these hidden files. If you don't see your module's address listed, add this to the file:
export PYTHONPATH="${PYTHONPATH}:/my/module/path"
Make sure the address points to the directory with your highest-level __init__.py file as python uses it to read the directory as a python package.

Use python -m site to conveniently view the
effect of the $PYTHONPATH env var on sys.path.
Code authors will often assume that current directory
is in your path:
$ export PYTHONPATH=.
If you intend to use . current directory,
then pay careful attention to which one's in use
at the time the script starts running.
You may want to view this value: os.getcwd()

I am maybe a bit late to the party but I can answer and maybe it helps.
1)Check once more your paths.
2)Check that you run with >./myProj arguments more arguments, and not
myProj arguments more arguments. Hope it helps even a bit

You could try using a relative import
from ..modules import process_query
def test_lyrics():
assert('lyrics' == process_query('paradise lyrics')[0])

Related

Unable to import from __init__.py [duplicate]

I'm having a hard time understanding how module importing works in Python (I've never done it in any other language before either).
Let's say I have:
myapp/__init__.py
myapp/myapp/myapp.py
myapp/myapp/SomeObject.py
myapp/tests/TestCase.py
Now I'm trying to get something like this:
myapp.py
===================
from myapp import SomeObject
# stuff ...
TestCase.py
===================
from myapp import SomeObject
# some tests on SomeObject
However, I'm definitely doing something wrong as Python can't see that myapp is a module:
ImportError: No module named myapp
In your particular case it looks like you're trying to import SomeObject from the myapp.py and TestCase.py scripts. From myapp.py, do
import SomeObject
since it is in the same folder. For TestCase.py, do
from ..myapp import SomeObject
However, this will work only if you are importing TestCase from the package. If you want to directly run python TestCase.py, you would have to mess with your path. This can be done within Python:
import sys
sys.path.append("..")
from myapp import SomeObject
though that is generally not recommended.
In general, if you want other people to use your Python package, you should use distutils to create a setup script. That way, anyone can install your package easily using a command like python setup.py install and it will be available everywhere on their machine. If you're serious about the package, you could even add it to the Python Package Index, PyPI.
The function import looks for files into your PYTHONPATH env. variable and your local directory. So you can either put all your files in the same directory, or export the path typing into a terminal::
export PYTHONPATH="$PYTHONPATH:/path_to_myapp/myapp/myapp/"
exporting path is a good way. Another way is to add a .pth to your site-packages location.
On my mac my python keeps site-packages in /Library/Python shown below
/Library/Python/2.7/site-packages
I created a file called awesome.pth at /Library/Python/2.7/site-packages/awesome.pth and in the file put the following path that references my awesome modules
/opt/awesome/custom_python_modules
You can try
from myapp.myapp import SomeObject
because your project name is the same as the myapp.py which makes it search the project document first
You need to have
__init__.py
in all the folders that have code you need to interact with.
You also need to specify the top folder name of your project in every import even if the file you tried to import is at the same level.
In your first myapp directory ,u can add a setup.py file and add two python code in setup.py
from setuptools import setup
setup(name='myapp')
in your first myapp directory in commandline , use pip install -e . to install the package
pip install on Windows 10 defaults to installing in 'Program Files/PythonXX/Lib/site-packages' which is a directory that requires administrative privileges. So I fixed my issue by running pip install as Administrator (you have to open command prompt as administrator even if you are logged in with an admin account). Also, it is safer to call pip from python.
e.g.
python -m pip install <package-name>
instead of
pip install <package-name>
In my case it was Windows vs Python surprise, despite Windows filenames are not case sensitive, Python import is. So if you have Stuff.py file you need to import this name as-is.
let's say i write a module
import os
my_home_dir=os.environ['HOME'] // in windows 'HOMEPATH'
file_abs_path=os.path.join(my_home_dir,"my_module.py")
with open(file_abs_path,"w") as f:
f.write("print('I am loaded successfully')")
import importlib
importlib.util.find_spec('my_module') ==> cannot find
we have to tell python where to look for the module. we have to add our path to the sys.path
import sys
sys.path.append(file_abs_path)
now importlib.util.find_spec('my_module') returns:
ModuleSpec(name='my_module', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fa40143e8e0>, origin='/Users/name/my_module.py')
we created our module, we informed python its path, now we should be able to import it
import my_module
//I am loaded successfully
This worked for me:
from .myapp import SomeObject
The . signifies that it will search any local modules from the parent module.
Short Answer:
python -m ParentPackage.Submodule
Executing the required file via module flag worked for me. Lets say we got a typical directory structure as below:
my_project:
| Core
->myScript.py
| Utils
->helpers.py
configs.py
Now if you want to run a file inside a directory, that has imports from other modules, all you need to do is like below:
python -m Core.myscript
PS: You gotta use dot notation to refer the submodules(Files/scripts you want to execute). Also I used python3.9+. So I didnt require neither any init.py nor any sys path append statements.
Hope that helps! Happy Coding!
If you use Anaconda you can do:
conda develop /Path/To/Your/Modules
from the Shell and it will write your path into a conda.pth file into the standard directory for 3rd party modules (site-packages in my case).
If you are using the IPython Console, make sure your IDE (e.g., spyder) is pointing to the right working directory (i.e., your project folder)
Besides the suggested solutions like the accepted answer, I had the same problem in Pycharm, and I didn't want to modify imports like the relative addressing suggested above.
I finally found out that if I mark my src/ (root directory of my python codes) as the source in Interpreter settings, the issue will be resolved.

Why does my python not add current working directory to the path?

I keep seeing sites mentioning that the directory that you execute 'python ' get added to the python path. For example on http://www.stereoplex.com/blog/understanding-imports-and-pythonpath, the author cd's to the /tmp folder then does 'print(sys.path)' and lo and behold, the /tmp folder appears in the path list. Here is me trying this out on my system (with 2.6.6 installed):
example structure:
app/
mymodule.py
inner_folder/
myscript.py
in myscript.py contains the line:
import mymodule.py
what I did:
cd app
python inner_folder/myscript.py # ImportError
Since I am executing the interpreter from the app/ directory, shouldn't 'app' be added to the python path? This is how a lot of the docs I have been reading have specified the behaviour should be.
Please enlighten!
(I have temporarily solved this by manually adding the folder I want into the environment but don't want to rely on that forever. Since many sites say this can be done, I'd like to reproduce it for myself)
It is the script's directory that is added, not the current directory. If you turn inner_folder/ into a package then you can use python -m inner_folder.myscript in order to run the script while having app/ added to sys.path.
Whether or not the current directory is in sys.path, import statements usually look like:
import mymodule
The code you wrote looks like:
import 'mymodule.py'

importing from parent directory

I have this kind of path architecture :
>main_path/
__init__.py
config/
__init__.py
common.py
app_1/
__init__.py
config.py
index.py
>
I'd like to be able to do so in config.py :
>from main_path.config import common
>
Though it does not work. Python tells me :
> $> pwd
..../main_path/app_1
$> python index.py
[...]
ImportError: No module named main_path.config
>
As far as I understand, this would be possible if i loaded everything up from the main_path, though the aim is to have multiple apps with a common config file.
I tried to add the parent directory to the __path__ in the app_1/__init__.py but it changed nothing.
My next move would be to have a symbolic link, though I don't really like this "solution", so if you have any idea to help me out, this would be much appreciated !
Thanks in advance !
According to the Modules documentation a module has to be in your PYTHONPATH environment variable to be imported. You can modify this within your program with something like:
import sys
sys.path.append('PATH_TO/config')
import common
For more information, you may want to see Modifying Python's Search Path in Installing Python Modules.
If you want to modify python's search path without having to set PYTHONPATH each time, you can add a path configuration file (.pth file) to a directory that is already on the python path.
This document describes it in detail: http://docs.python.org/install/#inst-search-path
The most convenient way is to add a
path configuration file to a directory
that’s already on Python’s path,
usually to the .../site-packages/
directory. Path configuration files
have an extension of .pth, and each
line must contain a single path that
will be appended to sys.path.
You can tweak your PYTHONPATH environment variable or edit sys.path.

PyLint "Unable to import" error - how to set PYTHONPATH?

I'm running PyLint from inside Wing IDE on Windows. I have a sub-directory (package) in my project and inside the package I import a module from the top level, ie.
__init__.py
myapp.py
one.py
subdir\
__init__.py
two.py
Inside two.py I have import one and this works fine at runtime, because the top-level directory (from which myapp.py is run) is in the Python path. However, when I run PyLint on two.py it gives me an error:
F0401: Unable to import 'one'
How do I fix this?
There are two options I'm aware of.
One, change the PYTHONPATH environment variable to include the directory above your module.
Alternatively, edit ~/.pylintrc to include the directory above your module, like this:
[MASTER]
init-hook='import sys; sys.path.append("/path/to/root")'
(Or in other version of pylint, the init-hook requires you to change [General] to [MASTER])
Both of these options ought to work.
The solution to alter path in init-hook is good, but I dislike the fact that I had to add absolute path there, as result I can not share this pylintrc file among the developers of the project. This solution using relative path to pylintrc file works better for me:
[MASTER]
init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc()))"
Note that pylint.config.PYLINTRC also exists and has the same value as find_pylintrc().
The problem can be solved by configuring pylint path under venv:
$ cat .vscode/settings.json
{
"python.pythonPath": "venv/bin/python",
"python.linting.pylintPath": "venv/bin/pylint"
}
Do you have an empty __init__.py file in both directories to let python know that the dirs are modules?
The basic outline when you are not running from within the folder (ie maybe from pylint's, though I haven't used that) is:
topdir\
__init__.py
functions_etc.py
subdir\
__init__.py
other_functions.py
This is how the python interpreter is aware of the module without reference to the current directory, so if pylint is running from its own absolute path it will be able to access functions_etc.py as topdir.functions_etc or topdir.subdir.other_functions, provided topdir is on the PYTHONPATH.
UPDATE: If the problem is not the __init__.py file, maybe just try copying or moving your module to c:\Python26\Lib\site-packages -- that is a common place to put additional packages, and will definitely be on your pythonpath. If you know how to do Windows symbolic links or the equivalent (I don't!), you could do that instead. There are many more options here: http://docs.python.org/install/index.html, including the option of appending sys.path with the user-level directory of your development code, but in practice I usually just symbolically link my local development dir to site-packages - copying it over has the same effect.
Create .pylintrc and add
[MASTER]
init-hook="from pylint.config import find_pylintrc;
import os, sys; sys.path.append(os.path.dirname(find_pylintrc()))"
I've added a new file pylintrc in the project's root directory with
[MASTER]
init-hook='import sys; sys.path.append(".")'
and it works for me in PyCharm IDE
1) sys.path is a list.
2) The problem is sometimes the sys.path is not your virtualenv.path and you want to use pylint in your virtualenv
3) So like said, use init-hook (pay attention in ' and " the parse of pylint is strict)
[Master]
init-hook='sys.path = ["/path/myapps/bin/", "/path/to/myapps/lib/python3.3/site-packages/", ... many paths here])'
or
[Master]
init-hook='sys.path = list(); sys.path.append("/path/to/foo")'
.. and
pylint --rcfile /path/to/pylintrc /path/to/module.py
I don't know how it works with WingIDE, but for using PyLint with Geany, I set my external command to:
PYTHONPATH=${PYTHONPATH}:$(dirname %d) pylint --output-format=parseable --reports=n "%f"
where %f is the filename, and %d is the path. Might be useful for someone :)
I had to update the system PYTHONPATH variable to add my App Engine path. In my case I just had to edit my ~/.bashrc file and add the following line:
export PYTHONPATH=$PYTHONPATH:/path/to/google_appengine_folder
In fact, I tried setting the init-hook first but this did not resolve the issue consistently across my code base (not sure why). Once I added it to the system path (probably a good idea in general) my issues went away.
Try
if __name__ == '__main__':
from [whatever the name of your package is] import one
else:
import one
Note that in Python 3, the syntax for the part in the else clause would be
from .. import one
On second thought, this probably won't fix your specific problem. I misunderstood the question and thought that two.py was being run as the main module, but that is not the case. And considering the differences in the way Python 2.6 (without importing absolute_import from __future__) and Python 3.x handle imports, you wouldn't need to do this for Python 2.6 anyway, I don't think.
Still, if you do eventually switch to Python 3 and plan on using a module as both a package module and as a standalone script inside the package, it may be a good idea to keep
something like
if __name__ == '__main__':
from [whatever the name of your package is] import one # assuming the package is in the current working directory or a subdirectory of PYTHONPATH
else:
from .. import one
in mind.
EDIT: And now for a possible solution to your actual problem. Either run PyLint from the directory containing your one module (via the command line, perhaps), or put the following code somewhere when running PyLint:
import os
olddir = os.getcwd()
os.chdir([path_of_directory_containing_module_one])
import one
os.chdir(olddir)
Basically, as an alternative to fiddling with PYTHONPATH, just make sure the current working directory is the directory containing one.py when you do the import.
(Looking at Brian's answer, you could probably assign the previous code to init_hook, but if you're going to do that then you could simply do the appending to sys.path that he does, which is slightly more elegant than my solution.)
I had this same issue and fixed it by installing pylint in my virtualenv and then adding a .pylintrc file to my project directory with the following in the file:
[Master]
init-hook='sys.path = list(); sys.path.append("./Lib/site-packages/")'
I found a nice answer. Edit your pylintrc and add the following in master
init-hook="import imp, os; from pylint.config import find_pylintrc; imp.load_source('import_hook', os.path.join(os.path.dirname(find_pylintrc()), 'import_hook.py'))"
If you want to walk up from the current module/file that was handed to pylint looking for the root of the module, this will do it.
[MASTER]
init-hook=sys.path += [os.path.abspath(os.path.join(os.path.sep, *sys.argv[-1].split(os.sep)[:i])) for i, _ in enumerate(sys.argv[-1].split(os.sep)) if os.path.isdir(os.path.abspath(os.path.join(os.path.sep, *sys.argv[-1].split(os.sep)[:i], '.git')))][::-1]
If you have a python module ~/code/mymodule/, with a top-level directory layout like this
~/code/mymodule/
├── .pylintrc
├── mymodule/
│   └── src.py
└── tests/
└── test_src.py
Then this will add ~/code/mymodule/ to your python path and allow for pylint to run in your IDE, even if you're importing mymodule.src in tests/test_src.py.
You could swap out a check for a .pylintrc instead but a git directory is usually what you want when it comes to the root of a python module.
Before you ask
The answers using import sys, os; sys.path.append(...) are missing something that justifies the format of my answer. I don't normally write code that way, but in this case you're stuck dealing with the limitations of the pylintrc config parser and evaluator. It literally runs exec in the context of the init_hook callback so any attempt to import pathlib, use multi-line statements, store something into variables, etc., won't work.
A less disgusting form of my code might look like this:
import os
import sys
def look_for_git_dirs(filename):
has_git_dir = []
filename_parts = filename.split(os.sep)
for i, _ in enumerate(filename_parts):
filename_part = os.path.abspath(os.path.join(os.path.sep, *filename_parts[:i]))
if os.path.isdir(os.path.join(filename_part, '.git')):
has_git_dir.append(filename_part)
return has_git_dir[::-1]
# don't use .append() in case there's < 1 or > 1 matches found
sys.path += look_for_git_dirs(sys.argv[-1])
I wish I could have used pathlib.Path(filename).parents it would have made things much easier.
The key is to add your project directory to sys.path without considering about the env variable.
For someone who use VSCode, here's a one-line solution for you if there's a base directory of your project:
[MASTER]
init-hook='base_dir="my_spider"; import sys,os,re; _re=re.search(r".+\/" + base_dir, os.getcwd()); project_dir = _re.group() if _re else os.path.join(os.getcwd(), base_dir); sys.path.append(project_dir)'
Let me explain it a little bit:
re.search(r".+\/" + base_dir, os.getcwd()).group(): find base directory according to the editing file
os.path.join(os.getcwd(), base_dir): add cwd to sys.path to meet command line environment
FYI, here's my .pylintrc:
https://gist.github.com/chuyik/f0ffc41a6948b6c87c7160151ffe8c2f
When you install Python, you can set up the path. If path is already defined then what you can do is within VS Code, hit Ctrl+Shift+P and type Python: Select Interpreter and select updated version of Python. Follow this link for more information, https://code.visualstudio.com/docs/python/environments
First, go to your VS Code then press "ctrl + shift + p"
Then search settings.json
Then paste the below code inside the settings.jason.I hope the problem will be solved.
{
"python.pythonPath": "venv/bin/python",
"python.linting.pylintPath": "venv/bin/pylint"
}
I got this error when trying to submit a PR. What I end up doing is just to add #pylint: disable=E0401 on the same line where "import" happens.
This helps me to pass the auto test.
One workaround that I only just discovered is to actually just run PyLint for the entire package, rather than a single file. Somehow, it manages to find imported module then.
I had the same problem and since i could not find a answer I hope this can help anyone with a similar problem.
I use flymake with epylint. Basically what i did was add a dired-mode-hook that check if the dired directory is a python package directory. If it is I add it to the PYTHONPATH. In my case I consider a directory to be a python package if it contains a file named "setup.py".
;;;;;;;;;;;;;;;;;
;; PYTHON PATH ;;
;;;;;;;;;;;;;;;;;
(defun python-expand-path ()
"Append a directory to the PYTHONPATH."
(interactive
(let ((string (read-directory-name
"Python package directory: "
nil
'my-history)))
(setenv "PYTHONPATH" (concat (expand-file-name string)
(getenv ":PYTHONPATH"))))))
(defun pythonpath-dired-mode-hook ()
(let ((setup_py (concat default-directory "setup.py"))
(directory (expand-file-name default-directory)))
;; (if (file-exists-p setup_py)
(if (is-python-package-directory directory)
(let ((pythonpath (concat (getenv "PYTHONPATH") ":"
(expand-file-name directory))))
(setenv "PYTHONPATH" pythonpath)
(message (concat "PYTHONPATH=" (getenv "PYTHONPATH")))))))
(defun is-python-package-directory (directory)
(let ((setup_py (concat directory "setup.py")))
(file-exists-p setup_py)))
(add-hook 'dired-mode-hook 'pythonpath-dired-mode-hook)
Hope this helps.
This is an old question but has no accepted answer, so I'll suggest this: change the import statement in two.py to read:
from .. import one
In my current environment (Python 3.6, VSCode using pylint 2.3.1) this clears the flagged statement.
In case anybody is looking for a way to run pylint as an external tool in PyCharm and have it work with their virtual environments (why I came to this question), here's how I solved it:
In PyCharm > Preferences > Tools > External Tools, Add or Edit an item for pylint.
In the Tool Settings of the Edit Tool dialog, set Program to use pylint from the python interpreter directory: $PyInterpreterDirectory$/pylint
Set your other parameters in the Parameters field, like: --rcfile=$ProjectFileDir$/pylintrc -r n $FileDir$
Set your working directory to $FileDir$
Now using pylint as an external tool will run pylint on whatever directory you have selected using a common config file and use whatever interpreter is configured for your project (which presumably is your virtualenv interpreter).
Mac user: If you're using Anaconda 3 w/ vsCode and have multiple environments, pointing to the following path via settings.json for vsCode works as well:
{
"python.pythonPath": "/Users/username/opt/anaconda3/bin/python",
"python.linting.pylintPath": "/Users/username/opt/anaconda3/bin/python"
}
If you are using Windows:
get the path of the python.exe inside the virtual environment you just created
it should be like this Z:\YourProjectFolder\Scripts\python.exe
then go to your vscode and edit the user settings.json
add this line: "python.pythonPath": "Z:\\YourProjectFolder\\Scripts\\python.exe"
save it and that should fix the issue
NOTE: the double backslash instead of single when putting it to the json file
{
"python.pythonPath": "Z:\\YourProjectFolder\\Scripts\\python.exe"
}
I found this worked nicely in my local .pylintrc file with a pipenv virtual environment:
[MASTER]
init-hook='import site; sys.path += site.getsitepackages()'
See this post for info about site packages.
Hello i was able to import the packages from different directory. I just did the following:
Note: I am using VScode
Steps to Create a Python Package
Working with Python packages is really simple. All you need to do is:
Create a directory and give it your package's name.
Put your classes in it.
Create a __init__.py file in the directory
For example: you have a folder called Framework where you are keeping all the custom classes there and your job is to just create a __init__.py file inside the folder named Framework.
And while importing you need to import in this fashion--->
from Framework import base
so the E0401 error disappears
Framework is the folder where you just created __init__.py and
base is your custom module which you are required to import into and work upon
Hope it helps!!!!
this all work for me!
.pylintrc
[MASTER]
; init-hook='import sys; sys.path.append("./venv/lib/python3.8/site-packages")'
; or
init-hook='import sys; sys.path.append(f"./venv/lib/python{sys.version[:3]}/site-packages");'
; or
;init-hook='from distutils.sysconfig import get_python_lib; sys.path.append(get_python_lib())'
; or
; init-hook='import site; sys.path.append(site.getsitepackages()[0])'
Maybe by manually appending the dir inside the PYTHONPATH?
sys.path.append(dirname)
if you using vscode,make sure your package directory is out of the _pychache__ directory.
If you are using Cython in Linux, I resolved removing module.cpython-XXm-X-linux-gnu.so files in my project target directory.
just add this code in .vscode/settings.json file
,"python.linting.pylintPath": "venv/bin/pylint"
This will notify the location of pylint(which is an error checker for python)

Import python package from local directory into interpreter

I'm developing/testing a package in my local directory. I want to import it in the interpreter (v2.5), but sys.path does not include the current directory. Right now I type in sys.path.insert(0,'.'). Is there a better way?
Also,
from . import mypackage
fails with this error:
ValueError: Attempted relative import in non-package
You can use relative imports only from in a module that was in turn imported as part of a package -- your script or interactive interpreter wasn't, so of course from . import (which means "import from the same package I got imported from") doesn't work. import mypackage will be fine once you ensure the parent directory of mypackage is in sys.path (how you managed to get your current directory away from sys.path I don't know -- do you have something strange in site.py, or...?)
To get your current directory back into sys.path there is in fact no better way than putting it there.
Keep it simple:
try:
from . import mymodule # "myapp" case
except:
import mymodule # "__main__" case
See the documentation for sys.path:
http://docs.python.org/library/sys.html#sys.path
To quote:
If the script directory is not available (e.g. if the interpreter is invoked interactively or if the script is read from standard input), path[0] is the empty string, which directs Python to search modules in the current directory first.
So, there's no need to monkey with sys.path if you're starting the python interpreter from the directory containing your module.
Also, to import your package, just do:
import mypackage
Since the directory containing the package is already in sys.path, it should work fine.
If you want to run an unmodified python script so it imports libraries from a specific local directory you can set the PYTHONPATH environment variable - e.g. in bash:
export PYTHONPATH=/home/user/my_libs
python myscript.py
If you just want it to import from the current working directory use the . notation:
export PYTHONPATH=.
python myscript.py
Inside a package if there is setup.py, then better to install it
pip install -e .
A simple way to make it work is to run your script from the parent directory using python's -m flag, e.g. python -m packagename.scriptname. Obviously in this situation you need an __init__.py file to turn your directory into a package.
Using sys.path should include current directory already.
Try:
import .
or:
from . import sth
however it may be not a good practice, so why not just use:
import mypackage
A bit late to the party, but this is what worked for me:
>>> import sys
>>> sys.path.insert(0, '')
Apparently, if there is an empty string, Python knows that it should look in the current directory. I did not have the empty string in sys.path, which caused this error.
Speaking for python3.. I wanted to use an improved version of a library that's installed in my environment. There are some extra print statements it makes to show that it and not the original lib is being used.
I placed the lib's folder next to the python script. Ran the script.. it ran with the local lib with the modifications.
Removed the folder and ran it again - this time it ran with the installed lib.
So, solution was simple : place the lib's folder (with same name as in your import statement) in your project folder. That does the job, at least at my end.
This is on a standard Linux Mint 20.04 system, with a python 3.8 virutal environment activated (so "(py3.8)" appears in my terminal when I'm in the virtual env)
You can import package_name if the package is a module: this needs you have init.py under the package and things that you want to use are needed to import in the init.py
Or if you want to import class under the package, you can use from package_name import class_name

Categories

Resources