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

Failed to start the example directly #11

Open
zepengliu opened this issue Sep 27, 2021 · 14 comments
Open

Failed to start the example directly #11

zepengliu opened this issue Sep 27, 2021 · 14 comments

Comments

@zepengliu
Copy link

itchat运行example报错

Failed to start the example directly。
Prompt that the src library is missing
But I Suspected it is a problem of source file path

@zepengliu
Copy link
Author

wrong way to import

it show there is a wrong way to import itchat.

the code can't import from the src.

please check it out

@wj-Mcat
Copy link
Collaborator

wj-Mcat commented Sep 27, 2021

This is the basic python path problem, which is depended on the evironment you use. When you use pycharm as your development IDE, it will set the project root directory into your python path list where the python program will search package at. In your case, when you clone the project into 机器人 directory, the python program will not find the src module which is the problem you are facing.

So, there are some solutions:

  • open the python-wechaty-puppet-itchat-main directory with pycharm, so it will find the src module.
  • add the 机器人/python-wechaty-puppet-itchat-main directory into you sys.path.

Hope that can help you fix the problem.

@lyleshaw lyleshaw linked a pull request Sep 27, 2021 that will close this issue
@wj-Mcat
Copy link
Collaborator

wj-Mcat commented Sep 27, 2021

@lyleshaw I think we shoule not rename itchat, which is the source project name, to itchat_wechaty. There are some problems that itchat lies under src directory.

  • when you publish the wechaty-puppet-itchat package, it will package itchat and wechaty-puppet-itchat modules into one package. So, when we install the wechaty-puppet-itchat package, it will install itchat and wechaty_puppet_itchat modules into your site-packages. And what's more, it will exist itchat package before you install it, so it will get into conflict.
  • itchat shoule not be the external pacakge, because it has been heavily modified. In this situation, I suggest that we can move src/itchat directory into src/wechaty_puppet_itchat/ directory. So it will be the sub module of wechaty_puppet_itchat .

we should not import wechaty_puppet_itchat from src package, which is included in published pacakge. You can get publishing detail in setup.py.

@wj-Mcat
Copy link
Collaborator

wj-Mcat commented Sep 27, 2021

@zepengliu for your prblem, I think you can set the python-wechaty-puppet-itchat-main as the sources in your pycharm: Setting -> Project Structure -> Sources. Following this setting, the program will automaticly add it into your sys.path.

This is the small trick and tool of pycharm. Hope that can help you fix this issue.

@lyleshaw
Copy link
Member

@lyleshaw I think we shoule not rename itchat, which is the source project name, to itchat_wechaty. There are some problems that itchat lies under src directory.

  • when you publish the wechaty-puppet-itchat package, it will package itchat and wechaty-puppet-itchat modules into one package. So, when we install the wechaty-puppet-itchat package, it will install itchat and wechaty_puppet_itchat modules into your site-packages. And what's more, it will exist itchat package before you install it, so it will get into conflict.
  • itchat shoule not be the external pacakge, because it has been heavily modified. In this situation, I suggest that we can move src/itchat directory into src/wechaty_puppet_itchat/ directory. So it will be the sub module of wechaty_puppet_itchat .

we should not import wechaty_puppet_itchat from src package, which is included in published pacakge. You can get publishing detail in setup.py.

Got it, I'll close that PR.

@wj-Mcat
Copy link
Collaborator

wj-Mcat commented Sep 27, 2021

A ha ~~~, you can contribute changes in this pr, because we have some discussions in this issue which is related to that pr. How do you think about @lyleshaw ?

@lyleshaw
Copy link
Member

A ha ~~~, you can contribute changes in this pr, because we have some discussions in this issue which is related to that pr. How do you think about @lyleshaw ?

That's sounds great.

@zepengliu
Copy link
Author

anotherimport question

first of all, through the method is success without the wrong to import src :Setting -> Project Structure -> Sources however,there is another wrong import .

@fangjiyuan
Copy link
Member

anotherimport question

first of all, through the method is success without the wrong to import src :Setting -> Project Structure -> Sources however,there is another wrong import .
同样的问题,ding可以收到,但是不回复dong。

@zepengliu
Copy link
Author

wrong import

actually.you can see there is no site-pakage in the file of sqlalchemy.ext like asyncio.please check the code again..

@zepengliu
Copy link
Author

the correct result

sorry,it is my problem. i should update sqlalchemy from 1.3.22 to 1.4.25 , it is ok now. I recommend you should write the sqlalchemy version in the requirement.txt also.

@lyleshaw
Copy link
Member

the correct result

sorry,it is my problem. i should update sqlalchemy from 1.3.22 to 1.4.25 , it is ok now. I recommend you should write the sqlalchemy version in the requirement.txt also.

Got it.

I'll update requirement.txt in the next PR.

Thanks for your suggestion~

@fangjiyuan
Copy link
Member

因为pycharm和vscode等IDE工具的文件目录机制不同,
为了对入门用户更加友好,建议添加本文件夹路径和src路径。

import sys,os
sys.path.append(os.getcwd()+"/src")
sys.path.append(os.getcwd())

@wj-Mcat
Copy link
Collaborator

wj-Mcat commented Sep 30, 2021

因为pycharm和vscode等IDE工具的文件目录机制不同, 为了对入门用户更加友好,建议添加本文件夹路径和src路径。

import sys,os sys.path.append(os.getcwd()+"/src") sys.path.append(os.getcwd())

Thanks for your solution for this problem. But this is the very simple python path issue for developer which should not be here.

What's more, If you use the python-wechaty-puppet-itchat package, you will pip install wechaty-puppet-itchat not
other than cloning the source code. So we should not add the src dir to python path variable list.

How do you think about it ? @fangjiyuan

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

Successfully merging a pull request may close this issue.

4 participants