简体   繁体   English

Python 更改 Windows 权限后找不到模块

[英]Python not finding modules after changing permissions on Windows

I recently got a new PC, and was messing around with Python. I tried editing a module in the Site Packages folder, and needed to change permission on the Python folder to do so.我最近买了一台新 PC,并且正在弄乱 Python。我尝试在 Site Packages 文件夹中编辑一个模块,并且需要更改 Python 文件夹的权限才能这样做。 However, after doing this, whenever I try to import a module, I get a ModuleNotFoundError .然而,在这样做之后,每当我尝试导入一个模块时,我都会得到一个ModuleNotFoundError I check the sys.path list, and the path is still in there.我检查了sys.path列表,路径仍然在那里。 Any suggestions as to what I could change to solve this?关于我可以改变什么来解决这个问题有什么建议吗?

You can always uninstall and reinstall Python. Also make sure you are running your computer as an admin.您可以随时卸载并重新安装 Python。还要确保您以管理员身份运行计算机。

It happens because some of the installation packages have already left in your home directory which you tried to install python from there.发生这种情况是因为一些安装包已经留在您的主目录中,您试图从那里安装 python。 They are n the form of '.package' (eg '.matplotlib') and as they left in the home directory python first goes there when you call the package which needs permission.它们的形式为“.package”(例如“.matplotlib”),当它们留在主目录中时,当您调用需要权限的 package 时,python 会首先进入该目录。 You need to delete them (the ones that are NOT in the python directory.), And then each time that you call the package. Python will search for at your given PATH.您需要删除它们(不在 python 目录中的那些。),然后每次调用 package 时。Python 将在您给定的路径中搜索。

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

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