问题
I'm getting the message:
>>> import some_module
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/david/.local/lib/python3.6/site-packages/some_module.py", line 1
def some_func():
^
SyntaxError: invalid character in identifier
When I am trying to import a local module from a package I installed with pip.
The structure of the package is as follows:
modules_and_packages
├── modules_and_packages
│ ├── __init__.py
│ └── some_module.py
├── setup.py
└── bin
└── cli_script
The code for some_module.py is as follows:
def some_func():
return 'hello'
Other relevant(?) files:
setup.py
setup(
name='some_module',
packages=['modules_and_packages'],
scripts=['bin/cli_script']
)
bin/cli_script
#!/usr/bin/env python3
import modules_and_packages
print('hello')
来源:https://stackoverflow.com/questions/61171637/syntaxerror-invalid-character-in-identifier-despite-there-being-almost-certa