python-wechaty-puppet-itchat
python-wechaty-puppet-itchat copied to clipboard
Failed to start the example directly
Failed to start the example directly。 Prompt that the src library is missing But I Suspected it is a problem of source file path
it show there is a wrong way to import itchat.
the code can't import from the src.
please check it out
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-maindirectory with pycharm, so it will find thesrcmodule. - add the
机器人/python-wechaty-puppet-itchat-maindirectory into yousys.path.
Hope that can help you fix the problem.
@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-itchatpackage, it will packageitchatandwechaty-puppet-itchatmodules into one package. So, when we install thewechaty-puppet-itchatpackage, it will installitchatandwechaty_puppet_itchatmodules into your site-packages. And what's more, it will existitchatpackage before you install it, so it will get into conflict. itchatshoule not be the external pacakge, because it has been heavily modified. In this situation, I suggest that we can movesrc/itchatdirectory intosrc/wechaty_puppet_itchat/directory. So it will be the sub module ofwechaty_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.
@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 I think we shoule not rename
itchat, which is the source project name, toitchat_wechaty. There are some problems thatitchatlies undersrcdirectory.
- when you publish the
wechaty-puppet-itchatpackage, it will packageitchatandwechaty-puppet-itchatmodules into one package. So, when we install thewechaty-puppet-itchatpackage, it will installitchatandwechaty_puppet_itchatmodules into your site-packages. And what's more, it will existitchatpackage before you install it, so it will get into conflict.itchatshoule not be the external pacakge, because it has been heavily modified. In this situation, I suggest that we can movesrc/itchatdirectory intosrc/wechaty_puppet_itchat/directory. So it will be the sub module ofwechaty_puppet_itchat.we should not import
wechaty_puppet_itchatfrom src package, which is included in published pacakge. You can get publishing detail insetup.py.
Got it, I'll close that PR.
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 ?
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.
first of all, through the method is success without the wrong to import src :Setting -> Project Structure -> Sources
however,there is another wrong import .
![]()
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。
actually.you can see there is no site-pakage in the file of sqlalchemy.ext like asyncio.please check the code again..
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.
![]()
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~
因为pycharm和vscode等IDE工具的文件目录机制不同, 为了对入门用户更加友好,建议添加本文件夹路径和src路径。
import sys,os sys.path.append(os.getcwd()+"/src") sys.path.append(os.getcwd())
因为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