简体   繁体   English

python 3.7无法导入模块

[英]python 3.7 can't import modules

I've been trying to import some packages for scraping comments but every time it downloads properly in terminal it has a module not found error in python. I've tried making a virtual environment, using sudo, using the path in the terminal download, changing the path in terminal and python itself.我一直在尝试导入一些包来抓取评论,但每次它在终端中正确下载时,它都会在 python 中出现模块未找到错误。我尝试使用 sudo 创建虚拟环境,使用终端下载中的路径,更改终端中的路径python 本身。 I've tracked down the path, setup.py and pyproject.toml to use as shown above but nothing (there wasn't pyproject and many setups but they all came from Unity or inside modules).我已经找到了路径、setup.py 和 pyproject.toml 来使用,如上所示,但什么也没有(没有 pyproject 和许多设置,但它们都来自 Unity 或内部模块)。 When I type 'pip3 list' all my modules appear.当我输入“pip3 list”时,我所有的模块都会出现。 I pasted the code from this website to change the directory and only edited the three paths to Users/Oscar/myenv/lib/python3.7/site-packages and got this: (the path of its code)我粘贴了这个网站的代码来更改目录,只编辑了三个路径到 Users/Oscar/myenv/lib/python3.7/site-packages 并得到了这个:(其代码的路径)

Current Working Directory  /Users/Oscar/Desktop/Python Scripts/Stolen Codes
Can't change the Current Working Directory
Current Working Directory  /Users/Oscar/Desktop/Python Scripts/Stolen Codes
Can't change the Current Working Directory
Current Working Directory  /Users/Oscar/Desktop/Python Scripts/Stolen Codes

moreover, though, when typing into the terminal 'pip3 install selenium ~/myenv/lib/python3.7/site-packages', I got this error:此外,虽然,当输入终端'pip3 install selenium ~/myenv/lib/python3.7/site-packages'时,我得到了这个错误:

ERROR: Directory '/Users/Oscar/myenv/lib/python3.7/site-packages' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.

I'm the admin so does anyone know how to fix?我是管理员所以有人知道如何解决吗? I've spent so long on the inte.net trying to import, sorry for the full-on text我花了很长时间在 inte.net 上尝试导入,对于完整的文本感到抱歉

From my personal experience(with other modules), uninstalling the module using pip uninstall selenium and reinstalling it using pip install selenium has worked.根据我个人的经验(使用其他模块),使用pip uninstall selenium卸载模块并使用pip install selenium重新安装它已经奏效。 There also might be dependencies that you are missing, and that could potentially result in your error.也可能有您遗漏的依赖项,这可能会导致您的错误。

first... upgrade pip: python -m pip install --upgrade pip after... pip install selenium首先...升级 pip: python -m pip install --upgrade pip之后... pip install selenium

If your problem is not solved again如果您的问题没有再次解决

Delete all python versions.删除所有 python 版本。 python reload. python 重新加载。 Install python from the install file, not from the command line.从安装文件而不是命令行安装 python。 It will ask if a path should be created during the installation phase?它会询问是否应该在安装阶段创建路径? Check that option.检查该选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM