小编Pho*_*nix的帖子

我无法在 ubuntu 中创建新的 virtualenv?

因此,我在 ubuntu 终端中安装了 virtualenv。我使用以下命令安装:

sudo apt install python3-virtualenv
pip install virtualenv
Run Code Online (Sandbox Code Playgroud)

但是当我尝试使用以下命令创建新的 virtualenv 时:

virtualenv -p python3 venv
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsArmFramework'
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

python virtualenv

17
推荐指数
2
解决办法
2万
查看次数

安装后导入包或创建新的 React 应用程序时将其包含在 index.html 中有何区别?

当我们在创建新的 React 应用程序时使用 create-react-app 。它创建多个文件。其中index.html是渲染的html应用程序,其中根据react应用程序App.jsx放置多个jsx元素我很好奇导入google字体、bootstrap、jquery和其他不同外部插件的最佳方法是什么?

据我研究,有两种导入外部模块的方法。例如。如果我们考虑从 cdn 导入 bootstrap:https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js

然后,导入的一种方法是将其放在 public/index.html 中:

# Rest of the index.html code
<div id="root"></div>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
# Rest of the index.html code

Run Code Online (Sandbox Code Playgroud)

另一种方法是使用安装 bootstrap npm i bootstrap@4.3.1 --save,然后将其作为 import 放入 src/index.js 。

上面的东西可以应用到多个地方。比如说,我们必须导入 popper.min.js 或 jquery.js 或导入 css 字体。哪个更好?将其放在index.html 中还是index.js 中?另外,将它放在两个不同的地方的主要区别是什么?

font-awesome reactjs react-bootstrap

4
推荐指数
1
解决办法
1083
查看次数

路由器和视图集如何配置它们的 url?

我正在阅读一段很长的代码。并被困在路由器和视图集如何自动配置其 URL 上。例如。views.py 文件是:

class UserViewSet(viewsets.ModelViewSet):
     authentication_classes = (BasicAuthentication,SessionAuthentication)
     permission_classes = (IsAuthenticated,)
     serializer_class = UserSerializer
     queryset = User.objects.all()
Run Code Online (Sandbox Code Playgroud)

与router对应的url是:

router = DefaultRouter()
router.register(r'users',views.UserViewSet,basename='user')
urlpatterns = router.urls
Run Code Online (Sandbox Code Playgroud)

在上述情况下,视图集中不同操作的相应 url 是什么,即列出、创建、检索、更新、partial_update 和 destroy,如视图集上的 djangorestframework 文档中所述:http ://www.tomchristie.com/rest -framework-2-docs/api-guide/viewsets

django django-rest-framework django-rest-viewsets

2
推荐指数
1
解决办法
1687
查看次数