Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name 'Project' #135

Open
bugwz opened this issue Mar 22, 2023 · 8 comments
Open

cannot import name 'Project' #135

bugwz opened this issue Mar 22, 2023 · 8 comments

Comments

@bugwz
Copy link

bugwz commented Mar 22, 2023

When i run pecan populate config/dev.py, i met the error:

(virtualenv) [shaman@142ba6b2f6af shaman]$ pecan populate config/dev.py
/home/shaman/virtualenv/lib/python3.6/site-packages/pecan/commands/base.py:51: RuntimeWarning: Unable to load plugin populate = shaman.commands.populate:PopulateCommand: cannot import name 'Project'
  warn("Unable to load plugin %s: %s" % (ep, e), RuntimeWarning)
usage: pecan [-h] [--version] command ...

positional arguments:
  command
    serve     Serves a Pecan web application
    shell     Open an interactive shell with the Pecan app loaded
    create    Creates the file layout for a new Pecan scaffolded project

optional arguments:
  -h, --help  show this help message and exit
  --version   show program's version number and exit

pecan: argument command: invalid choice: 'populate' (choose from 'serve', 'shell', 'create')
(virtualenv) [shaman@142ba6b2f6af shaman]$

My env is:

(virtualenv) [shaman@142ba6b2f6af shaman]$ pip --version
pip 21.3.1 from /home/shaman/virtualenv/lib/python3.6/site-packages/pip (python 3.6)
(virtualenv) [shaman@142ba6b2f6af shaman]$ python --version
Python 3.6.8
(virtualenv) [shaman@142ba6b2f6af shaman]$ pip list
Package            Version     Editable project location
------------------ ----------- -------------------------
alembic            0.8.6
beautifulsoup4     4.11.2
certifi            2022.12.7
chardet            4.0.0
CherryPy           8.9.1
decorator          5.1.1
enum34             1.1.10
greenlet           2.0.2
gunicorn           19.6.0
idna               2.10
importlib-metadata 4.8.3
ipython            5.0.0
ipython-genutils   0.2.0
Jinja2             2.11.3
logutils           0.3.5
Mako               1.1.6
MarkupSafe         2.0.1
mock               5.0.1
notario            0.0.16
pecan              1.4.0
pecan-notario      0.0.3
pexpect            4.8.0
pickleshare        0.7.5
pika               1.2.0
pip                21.3.1
projects           1.0.9
prompt-toolkit     1.0.18
psycopg2           2.8.6
ptyprocess         0.7.0
Pygments           2.14.0
python-editor      1.0.4
PyYAML             6.0
requests           2.25.1
setuptools         59.6.0
shaman             0.1         /home/shaman/shaman
simplegeneric      0.8.1
six                1.16.0
soupsieve          2.3.2.post1
SQLAlchemy         1.4.0
termcolor          1.1.0
traitlets          4.3.3
typing_extensions  4.1.1
urllib3            1.26.15
urwid              2.1.2
waitress           2.0.0
wcwidth            0.2.6
WebOb              1.8.7
WebTest            3.0.0
wheel              0.37.1
WSGIserver         1.3
zipp               3.6.0

I found the Project is shaman's local class, i don't know how to fix it. Please~

@bugwz
Copy link
Author

bugwz commented Mar 22, 2023

Add some python's sys path info:

(virtualenv) [shaman@142ba6b2f6af shaman]$ python
Python 3.6.8 (default, Sep 10 2021, 09:13:53)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/home/shaman/virtualenv/lib64/python36.zip', '/home/shaman/virtualenv/lib64/python3.6', '/home/shaman/virtualenv/lib64/python3.6/lib-dynload', '/usr/lib64/python3.6', '/usr/lib/python3.6', '/home/shaman/virtualenv/lib/python3.6/site-packages', '/home/shaman/shaman']

@dmick
Copy link
Member

dmick commented Mar 22, 2023

Why do you think that pecan has a populate command? Edit: oh, as @rakshithakamath94 points out, it's a custom Pecan command added by shaman to populate the postgresql database, I see

@rakshithakamath94
Copy link
Collaborator

Please check if you have cloned the branch python3 if not please go ahead and do that.

Here's what I did which worked for me. Let me know if it works for you!

pip3 install -r requirements.txt
python3 setup.py install
export ALEMBIC_CONFIG="alembic.ini"
export PECAN_CONFIG="config/dev.py"
cp -rf alembic.ini /usr/local/lib/python3.11/site-packages/shaman-0.1-py3.11.egg/
pecan populate config/dev.py
pecan serve config/run.py

@bugwz
Copy link
Author

bugwz commented Mar 22, 2023

Thanks~ @rakshithakamath94 @dmick

I checkout python3 branch, and it's ok to run following cmds.

rm -rf ~/virtualenv
virtualenv ~/virtualenv
source ~/virtualenv/bin/activate

# Some changed for `config/run.py` and `config/dev.py`
# ...


pip install -r requirements.txt
pip install "cherrypy>=3.8.0,<9.0.0"
python setup.py develop
pecan populate config/dev.py
pecan serve config/run.py

Additional information:

When i test that, i found the cmd pip install "cherrypy>=3.8.0,<9.0.0" is necessary, otherwise, will result the error:

ModuleNotFoundError: No module named 'cherrypy'

I think we can add this dependency, what do you think?

@rakshithakamath94
Copy link
Collaborator

yes will add it

@rakshithakamath94
Copy link
Collaborator

so the application is running?

@bugwz
Copy link
Author

bugwz commented Mar 22, 2023

@rakshithakamath94 yeah, it works. I created a PR to fix the dep problem of cherrypy #136

@gpingxu
Copy link

gpingxu commented Dec 25, 2023

What changes did you make to config? I am currently facing this issue and installing Cherrypy has not resolved it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants